6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 1:14 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: il65- macro assembly
PostPosted: Wed May 10, 2017 4:52 pm 
Offline

Joined: Fri Apr 14, 2017 1:58 pm
Posts: 13
il65- intermediate level 6502 language

Code:
<crlf> := #13, #10
<commentchar> := #00..09, #11, #12, #14..#255
<anychar> := #00..#124, #126..#255
<digit> := '0'..'9'
<hexdigit> := '0'..'9', 'A'..'F', 'a'..'f'
<bindigit> := '0', '1'
<stringchar> := #32..#255
<alpha> := 'A'..'Z', 'a'..'z', '_'
<alphanumeric> := { <alpha> | <digit> }

<addop> := '+', '-', 'or', 'xor', 'shr', 'shl'
<mulop> := '*', '/', 'div', 'mod', 'and'
<relop> := '=', '>', '<', '>=', '<=', '<>'
<identifier> := <alphanumeric> [ <alphanumeric> [...] ]
<decnumber> := <digit> [ <digit> [...] ]
<hexnumber> := <hexdigit> [ <hexdigit> [...] ]
<binnumber> := <bindigit> [ <bindigit> [...] ]
<anystring> := <anychar> [ <anychar> [...] ]
<commentstring> := <commentchar> [ <commentchar> [...] ]
<crlfstring> := <crlf> [ <crlf> [...] ]
<literalstring1> := '{' <anystring> '}'
<literalstring2> := '"' <stringchar> '"'
<string> := { <literalstring1> | <literalstring2> }
<float> := <decnumber> '.' <decnumber>
<number> := { <decnumber> | '$' <hexnumber> | '%' <binnumber> }
<comment> := '//' <commentstring> <crlfstring>
<literal> := { <number> | <float> | <string> }

// Expressions
<funccall> := <identifier> '(' [ <expressionlist> ] ')'
<varref> := <identifier>
<subexpression> := '(' <expression> ')'
<unaryminus> := '-' <factor>
<notfactor> := 'not' <factor>
<factor> := { <literal> | <notfactor> | <unaryminus> | <subexpression> | <varref> | <funccall> }
<mulexpr> := <factor> [ <mulop> <factor> [...] ]
<addexpr> := <mulexpr> [ <addop> <mulexpr> [...] ]
<expression> := <addexpr> [ <relop> <addexpr> ]
<expressionlist> := <expression> [ ',' <expression> [...] ]

// Symbols
<constdec> := <identifier> '=' <constexpression>
<vardec> := <identifier> [ '=' <constexpression> ]
<constdeclist> := <constdec> [ <constdec> [...] ]
<vardeclist> := <vardec> [ <vardec> [...] ]
<parameterdeclist> := <identifier> [ <identifier> [...] ]
<funcdec> := 'func' <identifier> '(' [ <parameterdeclist> ] ')' ':' <statementlist> 'endfunc'
<macrodec> := 'macro' <identifier> '(' [ <parameterdeclist> ] ')' ':' <statementlist> 'endmacro'

// Statements
<include> := 'include' <expression>
<const> := 'const' <constdeclist> 'endconst'
<var> := 'var' <vardeclist> 'endvar'
<assignment> := <identifier> ':=' <expression>
<return> := 'return' <expression>
<break> := 'break'
<proccall> := <identifier> '(' [ <expressionlist> ] ')'
<asm> := <expression>
<for> := 'for' <identifier> ':=' <expression> 'to' <expression> [ 'step' <expression> ] <statementlist> 'endfor'
<repeat> := 'repeat' <statementlist> 'until' <expression>
<while> := 'while' <expression> 'do' <statementlist> 'endwhile'
<caselabel> := 'case' <expressionlist> ':' <statement>
<caselabellist> := <caselabel> [ <caselabel> [...] ]
<case> := 'switch' <expression> 'of' <caselabellist> [ 'otherwise' <statementlist> ] 'endswitch'
<if> := 'if' <expression> 'then' <statementlist> [ 'elsif' <expression> 'then' <statementlist> ] [ 'else' <statementlist> ] 'endif'
<statement> := { <if> | <case> | <while> | <repeat> | <for> | <asm> | <proccall> | <break> | <return> | <assignment> | <var> | <const> | <include> }
<statementlist> := [ <statement> [ ';' <statement> [...] ] ] [ ';' ]
<mainprogstatement> := { <statement> | <funcdec> | <macrodec> }
<mainprogstatementlist> := <mainprogstatement> [ <mainprogstatement> [...] ]


This is a macro language i am developing. This language is interpreted AT COMPILE TIME, and produces 6502 assembly as output that is converted internaly into hex or s19 output. this is done so in order to compile the previously (http://forum.6502.org/viewtopic.php?f=2&t=4508) mentioned intermediate language (kind of 6502 llvm).

example :
Code:
macro u8add(a, b)
{
   assembly code here
  @a is replaced by the contents of A parameter,
  @b is replaced by the contents of B parameter etc
}
endmacro


the language is more powerfull than that (this example does not make justice) and uses a formal grammar to derive a descent recursive parser and an abstract syntax tree. the idea is to have a intermediate assembly (kind of llvm) between the compiler and the machine code, that translates everything at compile time into machine code.


Top
 Profile  
Reply with quote  
 Post subject: Re: il65- macro assembly
PostPosted: Wed May 10, 2017 6:56 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
Interesting. What does the final assembly output look like ? Does it produce native, inline code, or subroutine calls, or both (maybe adjustable) ?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 21 guests


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: