pine_write64
Write a 64-bit value in little-endian format to emulated RAM at an 8-byte aligned address. Accepts the value as a decimal string to preserve precision beyond 2^53.
Instructions
Write a 64-bit value (LE) to emulated RAM. Address must be 8-byte aligned. Pass the value as a decimal string to preserve precision past 2^53.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | Memory address (8-byte aligned) | |
| value | Yes | Decimal string (e.g. "18446744073709551615") |
Implementation Reference
- src/tools.ts:223-227 (handler)The handler for pine_write64. Parses the value as BigInt from the string input, then calls pine.write64(), and returns a formatted confirmation string.
case "pine_write64": { const v = BigInt(p.value as string); await pine.write64(addr(), v); return ok(`Wrote ${fmtHex(v)} → ${addrHex(addr())}`); } - src/tools.ts:110-121 (schema)The tool schema/definition for pine_write64. Describes writing a 64-bit LE value, requires address (integer) and value (decimal string pattern), with 8-byte alignment note.
{ name: "pine_write64", description: "Write a 64-bit value (LE) to emulated RAM. Address must be 8-byte aligned. Pass the value as a decimal string to preserve precision past 2^53.", inputSchema: { type: "object", required: ["address", "value"], properties: { address: { type: "integer", description: "Memory address (8-byte aligned)" }, value: { type: "string", pattern: "^[0-9]+$", description: "Decimal string (e.g. \"18446744073709551615\")" }, }, }, }, - src/pine.ts:254-259 (helper)The low-level write64 helper in PineClient. Allocates a 12-byte buffer (4 for addr + 8 for BigInt value), writes the address and BigUInt64LE value, then sends via the PINE protocol call with opcode Write64 (0x07).
async write64(addr: number, val: bigint): Promise<void> { const args = Buffer.alloc(12); args.writeUInt32LE(addr, 0); args.writeBigUInt64LE(val, 4); await this.call(Op.Write64, args); } - src/pine.ts:33-33 (helper)The Write64 opcode constant (0x07) used in the PINE protocol.
Write64: 0x07, - src/tools.ts:171-250 (registration)Registration of all tools including pine_write64 via server.setRequestHandler for both ListToolsRequestSchema and CallToolRequestSchema. The tool list (TOOLS array) and switch-case dispatch are both inside registerTools().
export function registerTools(server: Server, pine: PineClient): void { server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS })); server.setRequestHandler(CallToolRequestSchema, async (req) => { const { name, arguments: args = {} } = req.params; const p = args as Record<string, unknown>; const addr = () => p.address as number; switch (name) { case "pine_ping": { const v = await pine.getVersion(); return ok(`OK — emulator: ${v}`); } case "pine_get_info": { const [title, id, uuid, gameVer, status] = await Promise.all([ pine.getTitle().catch(() => "(unavailable)"), pine.getId().catch(() => "(unavailable)"), pine.getUuid().catch(() => "(unavailable)"), pine.getGameVersion().catch(() => "(unavailable)"), pine.getStatus(), ]); return ok( `Title: ${title}\n` + `Serial: ${id}\n` + `Disc CRC: ${uuid}\n` + `Game version: ${gameVer}\n` + `Status: ${status}`, ); } case "pine_get_status": { return ok(`Status: ${await pine.getStatus()}`); } case "pine_read8": return ok(`${addrHex(addr())}: ${fmtHex(await pine.read8(addr()))}`); case "pine_read16": return ok(`${addrHex(addr())}: ${fmtHex(await pine.read16(addr()))}`); case "pine_read32": return ok(`${addrHex(addr())}: ${fmtHex(await pine.read32(addr()))}`); case "pine_read64": return ok(`${addrHex(addr())}: ${fmtHex(await pine.read64(addr()))}`); case "pine_write8": { await pine.write8(addr(), p.value as number); return ok(`Wrote ${fmtHex(p.value as number)} → ${addrHex(addr())}`); } case "pine_write16": { await pine.write16(addr(), p.value as number); return ok(`Wrote ${fmtHex(p.value as number)} → ${addrHex(addr())}`); } case "pine_write32": { await pine.write32(addr(), p.value as number); return ok(`Wrote ${fmtHex(p.value as number)} → ${addrHex(addr())}`); } case "pine_write64": { const v = BigInt(p.value as string); await pine.write64(addr(), v); return ok(`Wrote ${fmtHex(v)} → ${addrHex(addr())}`); } case "pine_read_range": { const bytes = await pine.readRange(p.address as number, p.length as number); const hex = Array.from(bytes) .map((b) => b.toString(16).padStart(2, "0").toUpperCase()) .join(" "); return ok(`${addrHex(p.address as number)} [${bytes.length} bytes]:\n${hex}`); } case "pine_save_state": { await pine.saveState(p.slot as number); return ok(`Save state triggered for slot ${p.slot}`); } case "pine_load_state": { await pine.loadState(p.slot as number); return ok(`Load state triggered for slot ${p.slot}`); } default: throw new Error(`Unknown tool: ${name}`); } }); }