It is currently Mon Oct 20, 2014 4:01 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: BeebASM and strings
PostPosted: Sun Mar 24, 2013 6:09 pm 
Offline
 Profile

Joined: Sat Mar 10, 2012 10:27 pm
Posts: 41
I'm converting some code from ADE to BeebASM 1.04 (on Linux) and I've got a silly question. Unfortunately "beebasm" is too common in this forum to search on...!

In ADE I can do things like
Code:
date   ASET    "21 Mar 2013"

And then later
Code:
        ASC " (@date)"

Is it possible to define strings in this way with BeebASM ? I tried the obvious
Code:
date = "21 Mar 2103"

and this failed...

Similarly, in ADE I can do
Code:
verb    ASET    16
        DB @verb
        ASC "0.@verb"

A nice mix of integer and strings... can this be done in BeebASM?


Top
 
 Post subject: Re: BeebASM and strings
PostPosted: Mon Mar 25, 2013 8:01 am 
Offline
User avatar
 WWW  Profile

Joined: Thu Jan 10, 2008 7:45 pm
Posts: 472
Location: Treddle's Wharf, Chigley
I'm sure Rich TW will be along in a second, but if you want to store the sequence of bytes that make up the string with a label pointing to the first character, in BeebASM you use EQUS, the same as you would on a real Beeb.


Top
 
 Post subject: Re: BeebASM and strings
PostPosted: Mon Mar 25, 2013 9:55 am 
Offline
User avatar
 Profile

Joined: Mon Jan 07, 2008 6:46 pm
Posts: 380
Location: Málaga, Spain
Hello!

No, unfortunately this isn't possible in BeebAsm - the only supported type of string is a string literal, i.e. a string in quotes. The closest you could get I guess would be to use a macro to expand to EQUS "yourstring", e.g.

Code:
MACRO DATE
    EQUS "21 Mar 2013"
ENDMACRO

   ...

.versionstring
    EQUS "Version 1.00 ("
    DATE
    EQUS ")"

A little weird perhaps, but it kinda has the same effect.

I didn't bother with too much high-level support for strings, as they're not normally so important in assembly language programs, but I hope that's a reasonable enough work-around!

By the way, macros only appeared in a more recent version of BeebAsm (I don't think they're in 1.04), so you might have to compile the latest version - hopefully this is not too big a problem though.


Top
 
 Post subject: Re: BeebASM and strings
PostPosted: Mon Mar 25, 2013 11:49 am 
Offline
 Profile

Joined: Sat Mar 10, 2012 10:27 pm
Posts: 41
Yeah, once I updated to 1.08 (see crossthread), I ended up with a solution similar to that:

Code:
include "compile_date"
MACRO   VERSION_BYTE
        EQUB 1
ENDMACRO
MACRO   VERSION_STRING
        EQUS "0.01.1"
        COMPILE_DATE
ENDMACRO
MACRO   VERSION_DATE
        EQUS "21 Mar 2013"
ENDMACRO
MACRO   VERSION_NAME
        EQUS "MYCODE"
ENDMACRO

...
        JMP Language
        JMP Service
        EQUB &82
        EQUB Copyright-&8000
        VERSION_BYTE
        VERSION_NAME
        EQUB 0
        VERSION_STRING
        EQUS " ("
        VERSION_DATE
        EQUS ")"
.Copyright


"compile_date" is basically a "build" number for my internal testing so I can be sure the latest ROM was loaded into SWR to test against :-) It's built in the Makefile
Code:
compile_date: 6502src.txt
        (echo MACRO COMPILE_DATE ; echo "   EQUS \":`date +%Y%m%d-%H%M%S`\"" ; echo ENDMACRO ) > compile_date
        grep EQUS compile_date


Top
 
 Post subject: Re: BeebASM and strings
PostPosted: Fri Mar 29, 2013 10:27 pm 
Offline
 Profile

Joined: Sat Aug 22, 2009 7:45 pm
Posts: 34
sweh wrote:
Code:
MACRO   VERSION_STRING
        EQUS "0.01.1"
        COMPILE_DATE
ENDMACRO


VERSIONSTRING should be a.bc (eg 1.23) so the ROM header's version string is either exactly four characters (eg "1.23") or exactly 18 characters (eg "1.23 (12 Jan 2013)", eg:
EQUS "ROM TITLE"
EQUB 0
EQUS "1.23 (12 Jan 2013)"
.copyrightoffset
EQUB 0
EQUS "(C)Author Name"
EQUB 0


Top
 
 Post subject: Re: BeebASM and strings
PostPosted: Sun Mar 31, 2013 7:35 pm 
Offline
 Profile

Joined: Sat Mar 10, 2012 10:27 pm
Posts: 41
Colour me confused; where did this requirement come from? I never saw this BITD. Admittedly, about 85% of the ROMs (112 out of 135) I collected BITD follow your spec, but not all.

Heh, seem's even Acorn didn't follow that standard all the time :-)
Code:
00000000  4C 88 81 4C D5 80 C2 16   L..L....
00000008  01 56 69 65 77 53 74 6F   .ViewSto
00000010  72 65 00 31 2E 31 00 28   re.1.1.(
00000018  43 29 20 31 39 38 35 20   C) 1985
00000020  41 63 6F 72 6E 73 6F 66   Acornsof


Top
 
 Post subject: Re: BeebASM and strings
PostPosted: Mon Apr 01, 2013 9:01 am 
Offline
User avatar
 Profile

Joined: Mon Jan 07, 2008 6:46 pm
Posts: 380
Location: Málaga, Spain
sweh wrote:
Colour me confused; where did this requirement come from? I never saw this BITD. Admittedly, about 85% of the ROMs (112 out of 135) I collected BITD follow your spec, but not all.

No, I agree this is not an Acorn guideline and certainly not a requirement. Probably it's an attempt to try to retroactively apply some consistency to 'new' sideways ROMs, but, for example, the verbose form which includes the date is very much a RISC OS thing - this was the preferred format for module headers.


Top
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron