()
| 103 | } |
| 104 | |
| 105 | run() { |
| 106 | const source = new Uint8Array(this.readFileBuffer(this.sourcePath)); |
| 107 | let len = source.length; |
| 108 | let pos = 0; |
| 109 | let address = this.address; |
| 110 | |
| 111 | const parts = this.splitPath(this.sourcePath); |
| 112 | parts.extension = ".hex"; |
| 113 | if (this.outputDirectory) |
| 114 | parts.directory = this.outputDirectory; |
| 115 | if (this.outputName) |
| 116 | parts.name = this.outputName; |
| 117 | const outputPath = this.joinPath(parts); |
| 118 | |
| 119 | const output = new FILE(outputPath, "wb"); |
| 120 | |
| 121 | while (len) { |
| 122 | if (this.currentSegment != (address & 0xffff0000)) |
| 123 | output.writeString(this.generateSegment(address) + "\n"); |
| 124 | |
| 125 | const lineSize = len > 16 ? 16 : len; |
| 126 | |
| 127 | const buf = source.slice(pos, pos+lineSize); |
| 128 | pos += lineSize; |
| 129 | len -= lineSize; |
| 130 | |
| 131 | let out = ":" + ("00" + lineSize.toString(16)).slice(-2); |
| 132 | out += ("0000" + (address - this.currentSegment).toString(16)).slice(-4); |
| 133 | out += "00"; |
| 134 | for(let j=0; j<lineSize; j++) |
| 135 | out += ("00" + (buf[j].toString(16))).slice(-2); |
| 136 | |
| 137 | const chk = this.hexChecksum(out); |
| 138 | output.writeString((out + chk + "\n").toUpperCase()); |
| 139 | |
| 140 | address += lineSize; |
| 141 | } |
| 142 | |
| 143 | output.writeString(":00000001FF"); |
| 144 | output.close(); |
| 145 | } |
| 146 | } |
nothing calls this directly
no test coverage detected