1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-06-02 00:41:40 +00:00

Minor improvements

This commit is contained in:
Karol Stasiak 2019-01-05 01:04:08 +01:00
parent 4db1126b01
commit 7d596f3ed6
5 changed files with 34 additions and 7 deletions

View File

@ -21,6 +21,9 @@ It is not allowed in any other places.
String literals can be used as either array initializers or expressions of type `pointer`.
If a string literal is used as an expression, then the text data will be located in the default code segment,
regardless of which code segment the current function is located it. This may be subject to change in future releases.
String literals are surrounded with double quotes and optionally followed by the name of the encoding:
"this is a string" ascii
@ -101,6 +104,10 @@ An array is initialized with either:
* `@word_be` like the above, but opposite:
`@word_be [$1122]` is equivalent to `[$11, $22]`
* `@long` (=`@long_le`), `@long_be`: similar, but with four bytes
`@long [$11223344]` is equivalent to `[$44, $33, $22, $11]`
`@long_be [$11223344]` is equivalent to `[$11, $22, $33, $44]`
* a list of byte literals and/or other array initializers, surrounded by brackets:

View File

@ -24,7 +24,7 @@
<Keywords name="Folders in comment, open"></Keywords>
<Keywords name="Folders in comment, middle"></Keywords>
<Keywords name="Folders in comment, close"></Keywords>
<Keywords name="Keywords1">void byte sbyte ubyte array word farword pointer farpointer long word_be word_le file int8 int16 int24 int32 int40 int48 int56 int64 signed8 fast</Keywords>
<Keywords name="Keywords1">void byte sbyte ubyte array word farword pointer farpointer long word_be word_le long_be long_le file int8 int16 int24 int32 int40 int48 int56 int64 signed8 fast</Keywords>
<Keywords name="Keywords2">if else for return while do asm extern import segment break continue default alias enum</Keywords>
<Keywords name="Keywords3">defaultz petscii ascii scr petscr pet atascii atari bbc sinclair apple2 jis jisx iso_de iso_yu iso_no iso_dk iso_se iso_fi petsciiz asciiz scrz petscrz petz atasciiz atariz bbcz sinclairz apple2z jisz jisxz iso_dez iso_yuz iso_noz iso_dkz iso_sez iso_fiz until to downto parallelto static stack ref const volatile paralleluntil inline noinline macro register kernal_interrupt interrupt reentrant hi lo sin cos tan nonet align</Keywords>
<Keywords name="Keywords4">&quot;sta &quot; &quot;lda &quot; &quot;jmp &quot; &quot;bit &quot; &quot;eor &quot; &quot;adc &quot; &quot;sbc &quot; &quot;ora &quot; &quot;and &quot; &quot;ldx &quot; &quot;ldy &quot; &quot;stx &quot; &quot;sty &quot; &quot;tax&quot; &quot;tay&quot; &quot;tya&quot; &quot;txa&quot; &quot;txs&quot; &quot;tsx&quot; &quot;sei&quot; &quot;cli&quot; &quot;clv&quot; &quot;clc&quot; &quot;cld&quot; &quot;sed&quot; &quot;sec&quot; &quot;bra &quot; &quot;beq &quot; &quot;bne &quot; &quot;bmi &quot; &quot;bpl &quot; &quot;bcc &quot; &quot;bcs &quot; &quot;bvs &quot; bvc &quot; &quot;jsr &quot; rts&quot; &quot;rti&quot; &quot;brk&quot; &quot;rol&quot; &quot;ror&quot; &quot;asl&quot; &quot;lsr&quot; &quot;inc &quot; &quot;dec &quot; &quot;cmp &quot; &quot;cpx &quot; &quot;cpy &quot; inx iny dex dey pla pha plp hp phx plx phy ply &quot;stz &quot; &quot;ldz &quot; tza taz &quot;tsb &quot; &quot;trb &quot; ra txy tyx pld plb phb phd phk xce&#x000D;&#x000A;&#x000D;&#x000A;&quot;STA &quot; &quot;LDA &quot; &quot;JMP &quot; &quot;BIT &quot; &quot;EOR &quot; &quot;ADC &quot; &quot;SBC &quot; &quot;ORA &quot; &quot;AND &quot; &quot;LDX &quot; &quot;LDY &quot; &quot;STX &quot; &quot;STY &quot; &quot;TAX&quot; &quot;TAY&quot; &quot;TYA&quot; &quot;TXA&quot; &quot;TXS&quot; &quot;TSX&quot; &quot;SEI&quot; &quot;CLI&quot; &quot;CLV&quot; &quot;CLC&quot; &quot;CLD&quot; &quot;SED&quot; &quot;SEC&quot; &quot;BEQ &quot; &quot;BRA &quot; &quot;BNE &quot; &quot;BMI &quot; &quot;BPL &quot; &quot;BCC &quot; &quot;BCS &quot; &quot;BVS &quot; BVC &quot; &quot;JSR &quot; RTS&quot; &quot;RTI&quot; &quot;BRK&quot; &quot;ROL&quot; &quot;ROR&quot; &quot;ASL&quot; &quot;LSR&quot; &quot;INC &quot; &quot;DEC &quot; &quot;CMP &quot; &quot;CPX &quot; &quot;CPY &quot; INX INY DEX DEY PLA PHA PLP HP PHX PLX PHY PLY &quot;STZ &quot; &quot;LDZ &quot; TZA TAZ &quot;TSB &quot; &quot;TRB &quot; RA TXY TYX PLD PLB PHB PHD PHK XCE</Keywords>

View File

@ -38,6 +38,12 @@ object MosExpressionCompiler extends AbstractExpressionCompiler[AssemblyLine] {
case RegisterVariable(MosRegister.YA, _) => List(
AssemblyLine(LDA, Immediate, expr.hiByte),
AssemblyLine(LDY, Immediate, expr.loByte))
case RegisterVariable(MosRegister.XY, _) => List(
AssemblyLine(LDY, Immediate, expr.hiByte),
AssemblyLine(LDX, Immediate, expr.loByte))
case RegisterVariable(MosRegister.YX, _) => List(
AssemblyLine(LDX, Immediate, expr.hiByte),
AssemblyLine(LDY, Immediate, expr.loByte))
case m: VariableInMemory =>
val elidability = if (m.isVolatile) Elidability.Volatile else Elidability.Elidable
val addrMode = if (m.zeropage) ZeroPage else Absolute

View File

@ -264,13 +264,27 @@ case class ProcessedContents(processor: String, values: ArrayContents) extends A
override def getAllExpressions: List[Expression] = processor match {
case "word" | "word_le" =>
values.getAllExpressions.flatMap(expr => List(
FunctionCallExpression("lo", List(expr)),
FunctionCallExpression("hi", List(expr))
FunctionCallExpression("lo", List(expr)).pos(expr.position),
FunctionCallExpression("hi", List(expr)).pos(expr.position)
))
case "word_be" =>
values.getAllExpressions.flatMap(expr => List(
FunctionCallExpression("hi", List(expr)),
FunctionCallExpression("lo", List(expr))
FunctionCallExpression("hi", List(expr)).pos(expr.position),
FunctionCallExpression("lo", List(expr)).pos(expr.position)
))
case "long" | "long_le" =>
values.getAllExpressions.flatMap(expr => List(
FunctionCallExpression("byte", List(expr)).pos(expr.position),
FunctionCallExpression("byte", List(FunctionCallExpression(">>", List(expr, LiteralExpression(8, 1))).pos(expr.position))).pos(expr.position),
FunctionCallExpression("byte", List(FunctionCallExpression(">>", List(expr, LiteralExpression(16, 1))).pos(expr.position))).pos(expr.position),
FunctionCallExpression("byte", List(FunctionCallExpression(">>", List(expr, LiteralExpression(24, 1))).pos(expr.position))).pos(expr.position)
))
case "long_be" =>
values.getAllExpressions.flatMap(expr => List(
FunctionCallExpression("byte", List(FunctionCallExpression(">>", List(expr, LiteralExpression(24, 1))).pos(expr.position))).pos(expr.position),
FunctionCallExpression("byte", List(FunctionCallExpression(">>", List(expr, LiteralExpression(16, 1))).pos(expr.position))).pos(expr.position),
FunctionCallExpression("byte", List(FunctionCallExpression(">>", List(expr, LiteralExpression(8, 1))).pos(expr.position))).pos(expr.position),
FunctionCallExpression("byte", List(expr)).pos(expr.position)
))
}

View File

@ -262,7 +262,7 @@ abstract class AbstractAssembler[T <: AbstractCode](private val program: Program
for (item <- items) {
env.eval(item) match {
case Some(c) => writeByte(bank, index, c)
case None => log.error(s"Non-constant contents of array `$name`")
case None => log.error(s"Non-constant contents of array `$name`", item.position)
}
bank0.occupied(index) = true
bank0.initialized(index) = true
@ -367,7 +367,7 @@ abstract class AbstractAssembler[T <: AbstractCode](private val program: Program
for (item <- items) {
env.eval(item) match {
case Some(c) => writeByte(bank, index, c)
case None => log.error(s"Non-constant contents of array `$name`")
case None => log.error(s"Non-constant contents of array `$name`", item.position)
}
index += 1
}