mirror of
https://github.com/irmen/prog8.git
synced 2024-08-11 21:29:03 +00:00
clarify use of direct-memory in functions that modify in place such as rol/swap
This commit is contained in:
parent
0bf00d1ca4
commit
52f9956e92
@ -60,7 +60,7 @@ class PtAssignTarget(position: Position) : PtNode(position) {
|
|||||||
get() {
|
get() {
|
||||||
return when(val tgt = children.single()) {
|
return when(val tgt = children.single()) {
|
||||||
is PtIdentifier -> tgt.type
|
is PtIdentifier -> tgt.type
|
||||||
is PtArrayIndexer -> tgt.type // TODO array to elt type?
|
is PtArrayIndexer -> tgt.type
|
||||||
is PtMemoryByte -> tgt.type
|
is PtMemoryByte -> tgt.type
|
||||||
else -> throw AssemblyError("weird target $tgt")
|
else -> throw AssemblyError("weird target $tgt")
|
||||||
}
|
}
|
||||||
|
@ -388,8 +388,8 @@ private fun createAssemblyAndAssemble(program: Program,
|
|||||||
// to help clean up the code that still depends on them.
|
// to help clean up the code that still depends on them.
|
||||||
// removeAllVardeclsFromAst(program)
|
// removeAllVardeclsFromAst(program)
|
||||||
|
|
||||||
println("*********** AST RIGHT BEFORE ASM GENERATION *************")
|
// println("*********** AST RIGHT BEFORE ASM GENERATION *************")
|
||||||
printProgram(program)
|
// printProgram(program)
|
||||||
|
|
||||||
val assembly = asmGeneratorFor(program, errors, symbolTable, compilerOptions).compileToAssembly()
|
val assembly = asmGeneratorFor(program, errors, symbolTable, compilerOptions).compileToAssembly()
|
||||||
errors.report()
|
errors.report()
|
||||||
|
@ -841,11 +841,13 @@ rol(x)
|
|||||||
while the highest bit will become the new Carry flag value.
|
while the highest bit will become the new Carry flag value.
|
||||||
(essentially, it is a 9-bit or 17-bit rotation)
|
(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).
|
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)
|
rol2(x)
|
||||||
Like ``rol`` but now as 8-bit or 16-bit rotation.
|
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.
|
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).
|
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)
|
ror(x)
|
||||||
Rotate the bits in x (byte or word) one position to the right.
|
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.
|
while bit 0 will become the new Carry flag value.
|
||||||
(essentially, it is a 9-bit or 17-bit rotation)
|
(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).
|
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)
|
ror2(x)
|
||||||
Like ``ror`` but now as 8-bit or 16-bit rotation.
|
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.
|
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).
|
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)
|
sizeof(name)
|
||||||
Number of bytes that the object 'name' occupies in memory. This is a constant determined by the data type of
|
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(x, y)
|
||||||
Swap the values of numerical variables (or memory locations) x and y in a fast way.
|
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)
|
memory(name, size, alignment)
|
||||||
Returns the address of the first location of a statically "reserved" block of memory of the given size in bytes,
|
Returns the address of the first location of a statically "reserved" block of memory of the given size in bytes,
|
||||||
|
@ -3,10 +3,8 @@ TODO
|
|||||||
|
|
||||||
For next release
|
For next release
|
||||||
^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^
|
||||||
- vm: check array type in PtAssignTarget
|
|
||||||
- vm: animals example game breaks after adding first new animal...
|
- 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)
|
- 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
|
- 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?
|
- add McCarthy evaluation to shortcircuit and/or expressions. First do ifs by splitting them up? Then do expressions that compute a value?
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user