1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-07-04 16:29:52 +00:00

Slowly move towards removing the farword alias

This commit is contained in:
Karol Stasiak 2019-07-09 22:03:53 +02:00
parent 4ab45aba2e
commit 62f79388bd
7 changed files with 49 additions and 50 deletions

View File

@ -12,7 +12,7 @@ Millfork puts extra limitations on which types can be used in which contexts.
(alias: `int16`)
* `int24` 3-byte value of undefined signedness, defaulting to unsigned
(alias: `farword`; this alias is deprecated and might be removed in the future)
(alias: `farword`; this alias is deprecated and will be removed in the future)
* `long` 4-byte value of undefined signedness, defaulting to unsigned
(alias: `int32`)

View File

@ -257,7 +257,7 @@ object AbstractExpressionCompiler {
size match {
case 1 => b
case 2 => w
case 3 => env.get[Type]("farword")
case 3 => env.get[Type]("int24")
case 4 => env.get[Type]("long")
}
case GeneratedConstantExpression(_, typ) => typ

View File

@ -323,7 +323,7 @@ object Z80ExpressionCompiler extends AbstractExpressionCompiler[ZLine] {
ZLine.ldAbs8(A, v, 2), ZLine.ld8(E, A))
}
case ZExpressionTarget.DEHL =>
// TODO: signed farwords
// TODO: signed int24s
if (ctx.options.flag(CompilationFlag.EmitIntel8080Opcodes)) {
List(ZLine.ldAbs16(HL, v), ZLine.ldAbs8(A, v, 2), ZLine.ld8(E, A), ZLine.ldImm8(D, 0))
} else {
@ -337,7 +337,7 @@ object Z80ExpressionCompiler extends AbstractExpressionCompiler[ZLine] {
case 4 => target match {
case ZExpressionTarget.NOTHING => Nil
case ZExpressionTarget.DEHL =>
// TODO: signed farwords
// TODO: signed int24s
if (ctx.options.flag(CompilationFlag.EmitZ80Opcodes)) {
List(ZLine.ldAbs16(HL, v), ZLine.ldAbs16(DE, v.toAddress + 2))
} else if (ctx.options.flag(CompilationFlag.EmitIntel8080Opcodes)) {
@ -377,7 +377,7 @@ object Z80ExpressionCompiler extends AbstractExpressionCompiler[ZLine] {
List(ZLine.ldViaIxy(x, L, v.baseOffset), ZLine.ldViaIxy(x, H, v.baseOffset + 1), ZLine.ldImm16(DE, 0))
}
case 3 => target match {
// TODO: signed farwords
// TODO: signed int24s
case ZExpressionTarget.NOTHING => Nil
case ZExpressionTarget.EHL =>
List(ZLine.ldViaIxy(x, L, v.baseOffset), ZLine.ldViaIxy(x, H, v.baseOffset + 1), ZLine.ldViaIxy(x, E, v.baseOffset + 2))
@ -420,7 +420,7 @@ object Z80ExpressionCompiler extends AbstractExpressionCompiler[ZLine] {
loadHL ++ List(ZLine.ld8(A,MEM_HL), ZLine.register(INC_16, HL), ZLine.ld8(H, MEM_HL), ZLine.ld8(L, A), ZLine.ldImm16(DE, 0))
}
case 3 => target match {
// TODO: signed farwords
// TODO: signed int24s
case ZExpressionTarget.NOTHING => Nil
case ZExpressionTarget.EHL =>
loadHL2 ++ List(

View File

@ -437,7 +437,6 @@ class Environment(val parent: Option[Environment], val prefix: String, val cpuFa
addThing(BasicPlainType("int128", 16), None)
val p = DerivedPlainType("pointer", w, isSigned = false, isPointy = true)
addThing(p, None)
// addThing(DerivedPlainType("farpointer", get[PlainType]("farword"), isSigned = false), None)
addThing(DerivedPlainType("ubyte", b, isSigned = false, isPointy = false), None)
addThing(DerivedPlainType("sbyte", b, isSigned = true, isPointy = false), None)
addThing(Alias("unsigned8", "ubyte"), None)

View File

@ -577,10 +577,10 @@ object MfParser {
val doubleQuotedString: P[List[Char]] = P("\"" ~/ CharsWhile(c => c != '\"' && c != '\n' && c != '\r').?.! ~ "\"").map(_.toList)
def size(value: Long, wordLiteral: Boolean, farwordLiteral: Boolean, longLiteral: Boolean): Int = {
def size(value: Long, wordLiteral: Boolean, int24Literal: Boolean, int32Literal: Boolean): Int = {
val w = value > 255 || value < -0x80 || wordLiteral
val f = value > 0xffff || value < -0x8000 || farwordLiteral
val l = value > 0xffffff || value < -0x800000 || longLiteral
val f = value > 0xffff || value < -0x8000 || int24Literal
val l = value > 0xffffff || value < -0x800000 || int32Literal
if (l) 4 else if (f) 3 else if (w) 2 else 1
}

View File

@ -9,12 +9,12 @@ import org.scalatest.{FunSuite, Matchers}
*/
class FarwordTest extends FunSuite with Matchers {
test("Farword assignment") {
test("Int24 assignment") {
EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(
"""
| farword output3 @$c000
| farword output2 @$c004
| farword output1 @$c008
| int24 output3 @$c000
| int24 output2 @$c004
| int24 output1 @$c008
| void main () {
| output3 = $223344
| output2 = $223344
@ -28,11 +28,11 @@ class FarwordTest extends FunSuite with Matchers {
m.readMedium(0xc008) should equal(0x55)
}
}
test("Farword assignment 2") {
test("Int24 assignment 2") {
EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(
"""
| farword output3 @$c000
| farword output2 @$c004
| int24 output3 @$c000
| int24 output2 @$c004
| word output1 @$c008
| void main () {
| word w
@ -52,11 +52,11 @@ class FarwordTest extends FunSuite with Matchers {
}
}
test("Farword assignment 3") {
test("Int24 assignment 3") {
EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(
"""
| farword output0 @$c000
| farword output1 @$c003
| int24 output0 @$c000
| int24 output1 @$c003
| void main () {
| output0 = $112233
| output1 = $112233
@ -69,13 +69,13 @@ class FarwordTest extends FunSuite with Matchers {
m.readMedium(0xc003) should equal(0x111122)
}
}
test("Farword addition") {
test("Int24 addition") {
EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(
"""
| farword output @$c000
| int24 output @$c000
| void main () {
| word w
| farword l
| int24 l
| byte b
| w = $8000
| b = $8
@ -89,10 +89,10 @@ class FarwordTest extends FunSuite with Matchers {
m.readMedium(0xc000) should equal(0x58008)
}
}
test("Farword addition 2") {
test("Int24 addition 2") {
EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(
"""
| farword output @$c000
| int24 output @$c000
| void main () {
| output = 0
| output += $50000
@ -103,13 +103,13 @@ class FarwordTest extends FunSuite with Matchers {
m.readMedium(0xc000) should equal(0x58008)
}
}
test("Farword subtraction") {
test("Int24 subtraction") {
EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(
"""
| farword output @$c000
| int24 output @$c000
| void main () {
| word w
| farword l
| int24 l
| byte b
| w = $8000
| b = $8
@ -123,10 +123,10 @@ class FarwordTest extends FunSuite with Matchers {
m.readMedium(0xc000) should equal(0)
}
}
test("Farword subtraction 2") {
test("Int24 subtraction 2") {
EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(
"""
| farword output @$c000
| int24 output @$c000
| void main () {
| output = $58008
| output -= $50000
@ -137,10 +137,10 @@ class FarwordTest extends FunSuite with Matchers {
m.readMedium(0xc000) should equal(0)
}
}
test("Farword subtraction 3") {
test("Int24 subtraction 3") {
EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(
"""
| farword output @$c000
| int24 output @$c000
| void main () {
| output = $58008
| output -= w()
@ -157,10 +157,10 @@ class FarwordTest extends FunSuite with Matchers {
}
}
test("Farword AND") {
test("Int24 AND") {
EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(
"""
| farword output @$c000
| int24 output @$c000
| void main () {
| output = $FFFFFF
| output &= w()
@ -177,16 +177,16 @@ class FarwordTest extends FunSuite with Matchers {
}
}
test("Farword INC/DEC") {
test("Int24 INC/DEC") {
EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(
"""
| farword output0 @$c000
| farword output1 @$c004
| farword output2 @$c008
| farword output3 @$c00c
| farword output4 @$c010
| farword output5 @$c014
| farword output6 @$c018
| int24 output0 @$c000
| int24 output1 @$c004
| int24 output2 @$c008
| int24 output3 @$c00c
| int24 output4 @$c010
| int24 output5 @$c014
| int24 output6 @$c018
| void main () {
| output0 = 0
| output1 = $FF

View File

@ -259,9 +259,9 @@ class LongTest extends FunSuite with Matchers {
| long output5 @$c014
| long output6 @$c018
|
| farword f0 @$c020
| farword f1 @$c023
| farword f2 @$c026
| int24 f0 @$c020
| int24 f1 @$c023
| int24 f2 @$c026
| void main () {
| output0 = ll($91929394)
| output1 = lf($929394)
@ -278,7 +278,7 @@ class LongTest extends FunSuite with Matchers {
| long ll(long param) {
| return param
| }
| long lf(farword param) {
| long lf(int24 param) {
| return param
| }
| long lw(word param) {
@ -287,13 +287,13 @@ class LongTest extends FunSuite with Matchers {
| long lb(byte param) {
| return param
| }
| farword ff(farword param) {
| int24 ff(int24 param) {
| return param
| }
| farword fw(word param) {
| int24 fw(word param) {
| return param
| }
| farword fb(byte param) {
| int24 fb(byte param) {
| return param
| }
""".stripMargin) { m =>
@ -329,7 +329,7 @@ class LongTest extends FunSuite with Matchers {
| int64 xl(long param) {
| return param
| }
| int64 xf(farword param) {
| int64 xf(int24 param) {
| return param
| }
| int64 xw(word param) {