clarify use of direct-memory in functions that modify in place such as rol/swap

This commit is contained in:
Irmen de Jong 2022-05-16 22:39:03 +02:00
parent 0bf00d1ca4
commit 52f9956e92
4 changed files with 8 additions and 5 deletions

View File

@ -60,7 +60,7 @@ class PtAssignTarget(position: Position) : PtNode(position) {
get() {
return when(val tgt = children.single()) {
is PtIdentifier -> tgt.type
is PtArrayIndexer -> tgt.type // TODO array to elt type?
is PtArrayIndexer -> tgt.type
is PtMemoryByte -> tgt.type
else -> throw AssemblyError("weird target $tgt")
}

View File

@ -388,8 +388,8 @@ private fun createAssemblyAndAssemble(program: Program,
// to help clean up the code that still depends on them.
// removeAllVardeclsFromAst(program)
println("*********** AST RIGHT BEFORE ASM GENERATION *************")
printProgram(program)
// println("*********** AST RIGHT BEFORE ASM GENERATION *************")
// printProgram(program)
val assembly = asmGeneratorFor(program, errors, symbolTable, compilerOptions).compileToAssembly()
errors.report()

View File

@ -841,11 +841,13 @@ rol(x)
while the highest bit will become the new Carry flag value.
(essentially, it is a 9-bit or 17-bit rotation)
Modifies in-place, doesn't return a value (so can't be used in an expression).
You can rol a memory location directly by using the direct memory access syntax, so like ``rol(@($5000))``
rol2(x)
Like ``rol`` but now as 8-bit or 16-bit rotation.
It uses some extra logic to not consider the carry flag as extra rotation bit.
Modifies in-place, doesn't return a value (so can't be used in an expression).
You can rol a memory location directly by using the direct memory access syntax, so like ``rol2(@($5000))``
ror(x)
Rotate the bits in x (byte or word) one position to the right.
@ -853,11 +855,13 @@ ror(x)
while bit 0 will become the new Carry flag value.
(essentially, it is a 9-bit or 17-bit rotation)
Modifies in-place, doesn't return a value (so can't be used in an expression).
You can ror a memory location directly by using the direct memory access syntax, so like ``ror(@($5000))``
ror2(x)
Like ``ror`` but now as 8-bit or 16-bit rotation.
It uses some extra logic to not consider the carry flag as extra rotation bit.
Modifies in-place, doesn't return a value (so can't be used in an expression).
You can ror a memory location directly by using the direct memory access syntax, so like ``ror2(@($5000))``
sizeof(name)
Number of bytes that the object 'name' occupies in memory. This is a constant determined by the data type of
@ -867,6 +871,7 @@ sizeof(name)
swap(x, y)
Swap the values of numerical variables (or memory locations) x and y in a fast way.
You can swap two memory locations directly by using the direct memory access syntax, so like ``swap(@($5000), @($5001))``
memory(name, size, alignment)
Returns the address of the first location of a statically "reserved" block of memory of the given size in bytes,

View File

@ -3,10 +3,8 @@ TODO
For next release
^^^^^^^^^^^^^^^^
- vm: check array type in PtAssignTarget
- vm: animals example game breaks after adding first new animal...
- vm: add more instructions operating directly on memory instead of only registers? (translate assignment self-assigns)
- in-place modifiying functions (rol, ror, ..) don't accept a memory address but require a memory-read expression. that is weird.
- complete the Inliner
- add McCarthy evaluation to shortcircuit and/or expressions. First do ifs by splitting them up? Then do expressions that compute a value?