mirror of
https://github.com/KarolS/millfork.git
synced 2025-01-08 22:30:34 +00:00
Minor improvements
This commit is contained in:
parent
4db1126b01
commit
7d596f3ed6
@ -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:
|
||||
|
@ -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">"sta " "lda " "jmp " "bit " "eor " "adc " "sbc " "ora " "and " "ldx " "ldy " "stx " "sty " "tax" "tay" "tya" "txa" "txs" "tsx" "sei" "cli" "clv" "clc" "cld" "sed" "sec" "bra " "beq " "bne " "bmi " "bpl " "bcc " "bcs " "bvs " bvc " "jsr " rts" "rti" "brk" "rol" "ror" "asl" "lsr" "inc " "dec " "cmp " "cpx " "cpy " inx iny dex dey pla pha plp hp phx plx phy ply "stz " "ldz " tza taz "tsb " "trb " ra txy tyx pld plb phb phd phk xce

"STA " "LDA " "JMP " "BIT " "EOR " "ADC " "SBC " "ORA " "AND " "LDX " "LDY " "STX " "STY " "TAX" "TAY" "TYA" "TXA" "TXS" "TSX" "SEI" "CLI" "CLV" "CLC" "CLD" "SED" "SEC" "BEQ " "BRA " "BNE " "BMI " "BPL " "BCC " "BCS " "BVS " BVC " "JSR " RTS" "RTI" "BRK" "ROL" "ROR" "ASL" "LSR" "INC " "DEC " "CMP " "CPX " "CPY " INX INY DEX DEY PLA PHA PLP HP PHX PLX PHY PLY "STZ " "LDZ " TZA TAZ "TSB " "TRB " RA TXY TYX PLD PLB PHB PHD PHK XCE</Keywords>
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user