mirror of
https://github.com/irmen/prog8.git
synced 2026-04-21 17:16:33 +00:00
incbin in IR
This commit is contained in:
@@ -97,11 +97,12 @@ private fun BufferedWriter.writeLine(line: IRCodeLine) {
|
||||
write(line.ins.toString() + "\n")
|
||||
}
|
||||
is IRCodeInlineBinary -> {
|
||||
write("incbin \"${line.file}\"")
|
||||
if(line.offset!=null)
|
||||
write(",${line.offset}")
|
||||
if(line.length!=null)
|
||||
write(",${line.length}")
|
||||
write("!binary ")
|
||||
line.data.withIndex().forEach {(index, byte) ->
|
||||
write(byte.toString(16).padStart(2,'0'))
|
||||
if(index and 63 == 63 && index<line.data.size-1)
|
||||
write("\n!binary ")
|
||||
}
|
||||
write("\n")
|
||||
}
|
||||
is IRCodeLabel -> {
|
||||
|
||||
@@ -6,6 +6,7 @@ import prog8.code.SymbolTable
|
||||
import prog8.code.ast.*
|
||||
import prog8.code.core.*
|
||||
import prog8.intermediate.*
|
||||
import kotlin.io.path.readBytes
|
||||
import kotlin.math.pow
|
||||
|
||||
|
||||
@@ -204,7 +205,10 @@ class CodeGen(internal val program: PtProgram,
|
||||
is PtInlineAssembly -> IRInlineAsmChunk(node.assembly, node.position)
|
||||
is PtIncludeBinary -> {
|
||||
val chunk = IRCodeChunk(node.position)
|
||||
chunk += IRCodeInlineBinary(node.file, node.offset, node.length)
|
||||
val data = node.file.readBytes()
|
||||
.drop(node.offset?.toInt() ?: 0)
|
||||
.take(node.length?.toInt() ?: Int.MAX_VALUE)
|
||||
chunk += IRCodeInlineBinary(data.toByteArray())
|
||||
return chunk
|
||||
}
|
||||
is PtAddressOf,
|
||||
|
||||
Reference in New Issue
Block a user