--- nono/vm/iodevstream.h 2026/04/29 17:04:28 1.1 +++ nono/vm/iodevstream.h 2026/04/29 17:05:17 1.1.1.4 @@ -1,11 +1,11 @@ // // nono -// Copyright (C) 2019 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // #pragma once -#include "header.h" #include "device.h" // IODevice クラスへの Read/Write をストリームっぽく扱う。 @@ -79,6 +79,22 @@ class IODeviceStream Write16(data & 0xffff); } + // LE で2バイト書き込んでポインタを進める。addr はアラインしてなくてよい + void Write16LE(uint32 data) + { + Write8(data & 0xff); + Write8(data >> 8); + } + + // 文字列を書き込んでポインタを進める。 + void WriteString(const char *p) + { + while (*p) { + Write8(*p++); + } + Write8('\0'); + } + // アドレスも指定する版。ポインタは同様に進める uint64 Read8(uint32 a) { SetAddr(a); @@ -106,6 +122,6 @@ class IODeviceStream } private: - IODevice *dev; - uint32 addr; + IODevice *dev {}; + uint32 addr {}; };