Help with a code ported from SF

Discuss the Firewing language

Help with a code ported from SF

Postby skartalov » Wed Oct 30, 2013 12:37 pm

Hi,
can someone help me translate a little module, that I ported from SF:

Code: Select all
Module RIFE
Public Const endprog As ushort=25
Const SIZE_ARRAY as ushort = 25
 
public Const cname(size_array) As String = { _
"Acne",_
"Addison Disease",_
"Adenoma",_
"Adenomatous Pol Coli",_
"Adenoviridae Infect.",_
"Adhesions, Pelvic",_
"Adie Syndrome",_
"Adiposis Dolorosa",_
"Adrenal Gland Disea.",_
"Adrenal Hyperplasia",_
"Adrenoleukodystrophy",_
"Afibrinogenemia",_
"Agnosia", _
"Aicardi Syndrome",_
"Alagille Syndrome",_
"Alexander Disease",_
"Alkalosis",_
"Alkaptonuria",_
"Alopecia",_
"Alpha 1 Antitrypsin",_
"Alpha Mannosidosis",_
"Alphavirus Infect.  ",_
"Alzheimer Disease",_
"Amaurosis Fugax",_
"Amblyopia",_
}

Const STR_SIZE = SizeOf(cname) / SIZE_ARRAY

    ' get a name by index, uses 24 bit address...
public Function name(index As ushort) As String(STR_SIZE)
    Dim addr As ulong
     
    ' get address + offset, then load 24 bit address...
    addr = AddressOf(cname)           ' address of constant string array
    addr = addr + (index * STR_SIZE)  ' add the offset
    TBLPTRU = addr.Byte2 
    TBLPTRH = addr.Byte1
    TBLPTRL = addr.Byte0
     
    ' now read the string...
    FSR0 = AddressOf(result)
    do
       Asm
       TBLRD *+
       End Asm
       POSTINC0 = TABLAT
    loop Until TABLAT = 0                   ' look for null terminator
    TBLPTRU = 0                        ' reset upper 8 bits!!...
 End Function
 
End Module


The problem is the names TBLPTRx and FSR0, they are not declared.

How to modify this to suit the FIREWING compiler?
skartalov
 
Posts: 69
Joined: Sun Sep 15, 2013 1:12 pm

Re: Help with a code ported from SF

Postby David John Barker » Fri Nov 01, 2013 6:39 pm

You shouldn't need to port that code, you should be able to index the string array directly. For example:

Code: Select all
value = carray(index)


However, at the moment GCC imposes a limit on the max array size in bytes so you might hit a ceiling in that respect. However, I'm currently working on a fix. If you have any large data sets I can test with, please do email them to me - it would be very helpful...
User avatar
David John Barker
 
Posts: 491
Joined: Thu Nov 08, 2012 12:21 pm


Return to Language

Who is online

Users browsing this forum: No registered users and 5 guests

x