mirror of
https://github.com/KarolS/millfork.git
synced 2024-09-10 11:54:30 +00:00
Allow setting the size of the zeropage register from the command line.
This commit is contained in:
parent
516b44ad05
commit
bf47473162
@ -81,10 +81,11 @@ Default: native if targeting 65816, no otherwise.
|
||||
`.ini` equivalent: `prevent_jmp_indirect_bug`.
|
||||
Default: no if targeting a 65C02-compatible architecture or a non-6502 architecture, yes otherwise.
|
||||
|
||||
* `-fzp-register`, `-fno-zp-register` – Whether should reserve 4 bytes of zero page as a pseudoregister.
|
||||
Increases language features.
|
||||
* `-fzp-register=[0-15]`, `-fno-zp-register` – Sets the size of the zeropage pseudoregister.
|
||||
Increases language features on 6502-based targets.
|
||||
Recommended values: 2 or 4. Values higher than 4 are pointless.
|
||||
`.ini` equivalent: `zeropage_register`.
|
||||
Default: yes if targeting a 6502-based architecture, no otherwise.
|
||||
Default: 4 if targeting a 6502-based architecture, 0 otherwise.
|
||||
|
||||
* `-fdecimal-mode`, `-fno-decimal-mode` –
|
||||
Whether hardware decimal mode should be used (6502 only).
|
||||
|
@ -323,7 +323,7 @@ object Main {
|
||||
}.description("Whether should emit 65CE02 opcodes.")
|
||||
boolean("-fhuc6280-ops", "-fno-huc6280-ops").action { (c, v) =>
|
||||
c.changeFlag(CompilationFlag.EmitHudsonOpcodes, v)
|
||||
}.description("Whether should emit HuC6280huc6280 opcodes.")
|
||||
}.description("Whether should emit HuC6280 opcodes.")
|
||||
flag("-fno-65816-ops").action { c =>
|
||||
c.changeFlag(CompilationFlag.EmitEmulation65816Opcodes, b = false)
|
||||
c.changeFlag(CompilationFlag.EmitNative65816Opcodes, b = false)
|
||||
@ -344,12 +344,19 @@ object Main {
|
||||
boolean("-fillegals", "-fno-illegals").action { (c, v) =>
|
||||
c.changeFlag(CompilationFlag.EmitIllegals, v)
|
||||
}.description("Whether should emit illegal (undocumented) NMOS opcodes. Requires -O2 or higher to have an effect.")
|
||||
boolean("-fzp-register", "-fno-zp-register").action { (c, v) =>
|
||||
c.copy(zpRegisterSize = Some(if (v) 2 else 0)) // TODO
|
||||
}.description("Whether should use 2 bytes of zeropage as a pseudoregister.")
|
||||
flag("-fzp-register=[0-15]").description("Set the size of the zeropage pseudoregister (6502 only).").dummy()
|
||||
(0 to 15).foreach(i =>
|
||||
flag("-fzp-register="+i).action(c => c.copy(zpRegisterSize = Some(i))).hidden()
|
||||
)
|
||||
flag("-fzp-register").action { c =>
|
||||
c.copy(zpRegisterSize = Some(4))
|
||||
}.description("Alias for -fzp-register=4.")
|
||||
flag("-fno-zp-register").action { c =>
|
||||
c.copy(zpRegisterSize = Some(0))
|
||||
}.description("Alias for -fzp-register=0.")
|
||||
boolean("-fjmp-fix", "-fno-jmp-fix").action { (c, v) =>
|
||||
c.changeFlag(CompilationFlag.PreventJmpIndirectBug, v)
|
||||
}.description("Whether should prevent indirect JMP bug on page boundary.")
|
||||
}.description("Whether should prevent indirect JMP bug on page boundary (6502 only).")
|
||||
boolean("-fdecimal-mode", "-fno-decimal-mode").action { (c, v) =>
|
||||
c.changeFlag(CompilationFlag.DecimalMode, v)
|
||||
}.description("Whether hardware decimal mode should be used (6502 only).")
|
||||
|
@ -25,6 +25,7 @@ trait CliOption[T, O <: CliOption[T, O]] {
|
||||
private[cli] val _shortName: String
|
||||
private[cli] var _description: String = ""
|
||||
private[cli] var _hidden = false
|
||||
private[cli] var _dummy = false
|
||||
private[cli] var _maxEncounters = 1
|
||||
private[cli] var _minEncounters = 0
|
||||
private[cli] var _actualEncounters = 0
|
||||
@ -71,6 +72,11 @@ trait CliOption[T, O <: CliOption[T, O]] {
|
||||
this
|
||||
}
|
||||
|
||||
def dummy(): O = {
|
||||
_dummy = true
|
||||
this
|
||||
}
|
||||
|
||||
def minCount(count: Int): O = {
|
||||
_minEncounters = count
|
||||
this
|
||||
|
@ -41,16 +41,16 @@ class CliParser[T] {
|
||||
args match {
|
||||
case k :: v :: xs if mapOptions.contains(k) =>
|
||||
mapOptions(k) match {
|
||||
case p: ParamOption[T] => parseInner(p.encounter(v, context), xs)
|
||||
case p: ParamOption[T] if !p._dummy => parseInner(p.encounter(v, context), xs)
|
||||
case _ => ???
|
||||
}
|
||||
case k :: xs if mapFlags.contains(k) =>
|
||||
mapFlags(k) match {
|
||||
case p: FlagOption[T] =>
|
||||
case p: FlagOption[T] if !p._dummy =>
|
||||
parseInner(p.encounter(context), xs)
|
||||
case p: BooleanOption[T] =>
|
||||
case p: BooleanOption[T] if !p._dummy =>
|
||||
parseInner(p.encounter(k, context), xs)
|
||||
case p: NoMoreOptions[T] =>
|
||||
case p: NoMoreOptions[T] if !p._dummy =>
|
||||
p.encounter()
|
||||
xs.foldLeft(context)((t, x) => _default.encounter(x, t))
|
||||
case _ => ???
|
||||
|
Loading…
Reference in New Issue
Block a user