ときどきの雑記帖 RE* (新南口)
D is for Digital
Zガンダム@テレ玉
「シャアの帰還」
- 「レクリエーション」
- ヤザン vs ジェリド
- (クワトロがブライトに)「白髪が出ている」
- ハサウェイ(とチェーミンとミライさん)からの手紙
次回「ジュピトリス潜入」
ヴィレヴァン
角川さんから許可いただきまして‼️イオンコラボのフドあすパネルは‼️ヴィレヴァンが貰えるになりました‼️
— ヴィレッジヴァンガードイオンモール名取 (@vvnatori) September 2, 2025
いつまでも聖地を謳っている当店に置ける喜びで普通に狂いそうです。山本のバ先に山本がいる、ということになります。よろしくお願い致します。
(場所は移るかもしれないですが店内にはいます) pic.twitter.com/u69PsKVKMb
バイトしているというセリフはあったけど、 ヴィレヴァンでだったのか
bwk
[B! Rust] 【海外記事紹介】Unixの共同開発者ブライアン・カーニハン、RustやLinux、LLMについて大いに語る
氏の業績を紹介するのにC言語の開発(1972年)ではなく、書籍の出版(1978年)を出すのには違和感あり。 / 書籍の原題は“The C Programming Language”なので翻訳記事だとこうなっちゃうかもね。
大先生、Cの普及には大きな役割を果たしたと思うけど、 「開発」にそんなにコミットしてたっけ?
C (programming language) - Wikipedia
C[c] is a general-purpose programming language. It was created in the 1970s by Dennis Ritchie and remains widely used and influential.
Kernighan’s name became widely known through co-authorship of the first book on the C programming language (The C Programming Language) with Dennis Ritchie. Kernighan affirmed that he had no part in the design of the C language (“it’s entirely Dennis Ritchie’s work”).[7]
Interview with Brian Kernighan | Linux Journal
LJ: What was your part in the birth and destiny of the C language?
BK: I had no part in the birth of C, period. It’s entirely Dennis Ritchie’s work. I wrote a tutorial on how to use C for people at Bell Labs, and I twisted Dennis’s arm into writing a book with me. But, if he had been so motivated, he certainly could have done it without help. He’s a superb writer, as one can tell from the C reference manuals, which are his prose, untouched. I’ve profited a great deal from being part of the book, and I treasure Dennis as a friend, but I didn’t have anything to do with C.
カーニハンって、あのカーニハンですか!?現役だったのか……。リッチーも出場期待!!
どうやって(笑)>「リッチーも出場期待」
Dennis MacAlistair Ritchie (September 9, 1941 – c. October 12, 2011) was an American computer scientist.[3]
あとでスタッフがおいしくいただきました
- @hacker-news-jp.bsky.socialによる投稿 — Bluesky
- The staff ate it later | Hacker News
- The staff ate it later - Wikipedia
新宿西口
新宿西口、9月27日に東西つなぐ歩行者動線 車は南北通り抜け不可に - Impress Watch
あのバス停に地下に潜らず行けるようになるのか。 あ、でも渋谷駅行きのバス停、すでに移動してない?
tinylisp
- A Lisp in 99LOC | Hacker News
- Question about Lisp in 99 lines of C interpreter : r/lisp
- Robert-van-Engelen/tinylisp: Lisp in 99 lines of C and how to write one yourself
ファイルがたくさんあるけど
tinylisp.c | Lisp in 99 lines of C with double precision |
tinylisp-commented.c | commented version in an (overly) verbose C style |
tinylisp-opt.c | optimized version for speed and reduced memory use |
tinylisp-float.c | Lisp in 99 lines of C with single precision |
tinylisp-float-opt.c | optimized version with single precision |
lisp850.c | Lisp in 99 lines of C for the Sharp PC-G850 with BCD boxing |
lisp850-opt.c | optimized version for speed and reduced memory use |
tinylisp-extras.c | compile with -lreadline |
tinylisp.cが元祖で、あとはそれにいろいろくっつけたもの。といったところか。 んでtinylisp-commented.cが「親切に」コメントを入れたものと。
tinylisp/src/tinylisp-commented.c at main · Robert-van-Engelen/tinylisp
/* we only need two types to implement a Lisp interpreter:
I unsigned integer (either 16 bit, 32 bit or 64 bit unsigned)
L Lisp expression (double with NaN boxing)
I variables and function parameters are named as follows:
i any unsigned integer, e.g. a NaN-boxed ordinal value
t a NaN-boxed tag
L variables and function parameters are named as follows:
x,y any Lisp expression
n number
t list
f function, a lambda closure or Lisp primitive
p pair, a cons of two Lisp expressions
e,d environment, a list of pairs, e.g. created with (define v x)
v the name of a variable (an atom) or a list of variables */
#define I unsigned
#define L double
/* T(x) returns the tag bits of a NaN-boxed Lisp expression x */
#define T(x) *(unsigned long long*)&x >> 48
/* address of the atom heap is at the bottom of the cell stack */
#define A (char*)cell
/* number of cells for the shared stack and atom heap, increase N as desired */
#define N 1024
/* hp: top of the atom heap pointer, A+hp with hp=0 points to the first atom string in cell[]
sp: cell stack pointer, the stack starts at the top of cell[] with sp=N
safety invariant: hp <= sp<<3 */
I hp = 0, sp = N;
/* atom, primitive, cons, closure and nil tags for NaN boxing */
I ATOM = 0x7ff8, PRIM = 0x7ff9, CONS = 0x7ffa, CLOS = 0x7ffb, NIL = 0x7ffc;
/* cell[N] array of Lisp expressions, shared by the stack and atom heap */
L cell[N];
セルを収める型はdoubleで、NaN boxingを駆使していろいろ詰め込むと。 セルといってもそこにcarとcdrがあるわけではなく、 連続する2つのセルを一組として
/* construct pair (x . y) returns a NaN-boxed CONS */
L cons(L x, L y) {
cell[--sp] = x; /* push the car value x */
cell[--sp] = y; /* push the cdr value y */
if (hp > sp<<3) /* abort when out of memory */
abort();
return box(CONS, sp);
}
/* return the car of a pair or ERR if not a pair */
L car(L p) {
return (T(p) & ~(CONS^CLOS)) == CONS ? cell[ord(p)+1] : err;
}
/* return the cdr of a pair or ERR if not a pair */
L cdr(L p) {
return (T(p) & ~(CONS^CLOS)) == CONS ? cell[ord(p)] : err;
}
- 浮動小数点数とポインタを混在させるテクニック(NaN Boxing) - Kludge Factory
- NaNのビットパターンを使ってWebAssemblyからCPUの命令セットを推測する
- JavaScript で CPU が Intel かどうかを判定する(ついでに JIT を検知する)
- 無限大および NaN - IBM Documentation
- Lisp interpreter with GC in <750 lines of Odin (and <500 lines of C) | Hacker News
- GitHub - krig/LISP: Moved to Forgejo!
- Indices, not Pointers | Hacker News
- Joe Mckay - Indices, not Pointers
strftime
glibc/time/strftime_l.c at master · bminor/glibc
# ifdef strftime
# undef strftime
size_t strftime ();
# endif
*u++ = '%';
if (modifier != 0)
*u++ = modifier;
*u++ = format_char;
*u = '\0';
len = strftime (ubuf, sizeof ubuf, ufmt, tp);
if (len == 0 && ubuf[0] != '\0')
return 0;
cpy (len, ubuf);
}
break;
#endif
どういう設定のときにコンパイルさせる部分なのかはわからないけど、
size_t strftime ();
でprotptype宣言してからの
len = strftime (ubuf, sizeof ubuf, ufmt, tp);
は最新のGCCだとエラーになる?
BASIC
GW-BASICよりも古いBASICがオープンソースとして公開
Microsoft’s 6502 BASIC is now Open Source!
— Windows Dev Docs (@WindowsDocs) September 3, 2025
Pretty sure some of us are old enough to have used BASIC on 6502-based machines. https://t.co/1w8LUDpATM
- Microsoft Releases Historic 6502 BASIC - Microsoft Open Source Blog
- Microsoft Releases Historic 6502 Basic : r/programming
- Microsoft BASIC for 6502 Microprocessor – Version 1.1 | Hacker News
- microsoft/BASIC-M6502: Microsoft BASIC for 6502 Microprocessor - Version 1.1
- ビル・ゲイツが書いた48年前の「6502 BASIC」のソースコードをMicrosoftがオープンソース化 - GIGAZINE
- マイクロソフト、「6502 BASIC」をオープンソース化–「GitHub」でソースコード公開 - ZDNET Japan
ZDNetの記事に
当時のMicrosoft BASIC 1.1は、非常に洗練された言語だった。改良されたガベージコレクション機能を備えており、 わずか4KBのRAMしかない環境では、プログラムが使えるバイトを少しでも多く確保する必要があった。 また、FORループ変数のサポートも追加されており、BASIC特有の悪名高いGOTOコマンドに比べて大きな進歩だった。
とあるんだけど、FORって元祖にも当然あったし TINY BACICにもあるものだから「大きな進歩」というのは?🤔
で翻訳前の記事を調べると
MS-BASIC 1.1 introduced programming to a generation - now you can download it for free | ZDNET
For its day, MS-BASIC 1.1 was quite sophisticated. It included improved garbage collection. (When you only had 4K of RAM, you needed every byte your program could get its hands on.) It also supported FOR loop variables, which were a big improvement over BASIC’s infamous GOTO command.
It also supported FOR loop variables,
をどう解釈するかだなあ。
「サポートしていた」と「追加された(した)」は
ニュアンスがだいぶ違うような気がする…
それはまあおいといて、
公開されたソースコードは6502用Microsoft BASIC バージョン1.1。アセンブリ言語で記述されており、 MicrosoftのBill Gates氏とCommodoreのエンジニアJohn Feagans氏によって実装された修正がほどこされた “歴史的な”コード。STORDO と STORD0のラベルにはBill Gates氏によるイースターエッグが仕込まれているとのこと。
このイースターエッグに関してはHNでも話題になっていて
There’s the “WAIT 6502,X” Easter egg[0]!
Lines 6530 - 6539 are the “MICROSOFT!” that gets printed.
Line 4914 is the code to check the address passed to WAIT and, if correct, print the “MICROSOFT!”.
It really is inconspicuous. A source licensee definitely wouldn’t find it by quickly perusing.
ソースの6530行目から6539行目までに"MICROSOFT!“があって、 4914行からのコードでイースターエッグの処理をしていると。
んでその6530行から6539行がどうなっているかというと
241 ; 7.2362932E7
124
106
217
23
217 ; 73276.2515
122
103
211
315>
1文字ずつ8進表記されているとしてもそれっぽくは見えない。 しかしここで先ほどのHNの投稿の次の投稿を見ると
"".join(map(lambda n: chr((n & 0o77) + 64), reversed([0o241, 0o124, 0o106, 0o217, 0o23, 0o217, 0o122, 0o103, 0o211, 0o315])))
This python one-liner roughly recovers the hidden string out of defined bytes.
とある。 これを実行するとその結果は
MICROSOFTa
となる。
最後が!
じゃなくてa
なのが気になるけど
ASCIIだと(PETSCIIでは?という疑問はとりあえず忘れる)
a | 0x61 |
! | 0x21 |
だから、なにかあるのかもしれない。
追記:
PETSCII - Wikipedia
の表によれば、!
が0x61の位置にある
追記ここまで
そしてこのデータを使う4914行以降に何があるか確認すると (適当にコメントを追加した)
ZSTORDO - microsoft/BASIC-M6502
XLIST
.XCREF
IFN REALIO-3,<ZSTORDO=STORDO>
IFE REALIO-3,<
ZSTORD:! LDA POKER
CMPI 146 *31(8)*256 + 146(8) = 6502
BNE STORDO *下位バイト
LDA POKER+1
SBCI 31
BNE STORDO *上位バイト
STA POKER
TAY
LDAI 200
STA POKER+1
MRCHKR: LDXI 12 *'MICROSOFT!'の長さ
IF1,<
MRCHR: LDA 60000,X,>
IF2,<
MRCHR: LDA SINCON+36,X,> *'MICROSOFT!'の末尾のアドレスから逆方向に1文字ずつ取り出す
ANDI 77
STADY POKER *STA (POKER),Y
INY *256文字処理したら
BNE PKINC
INC POKER+1 *上位バイトを+1
PKINC: DEX *文字列のインデックスを-1
BNE MRCHR *10文字転送するまで
DEC ANDMSK *WAIT6502、N のNがANDMSKにある
BNE MRCHKR *N回繰り返し
RTS
IF2,<PURGE ZSTORD>>
.CREF
LIST
FADD5: JSR SHIFTR ;DO A LONG SHIFT.
のZSTORD
というラベルの付いた行からRTSまで。
前後を見るとここだけアセンブルリストに出ないようにしていたり(XLIST)
クロスリファレンスにラベルが出ないようにしたり(XCREF)
ととても怪しい😄
コメントにも書いたけど
STADY POKER
はSTA (POKER),Y
に展開されるマクロらしい
(同様のマクロ定義はほかにもあって、たとえば上記のコード片にもある
LDXI
やANDI
とか)
ところで先ほどのPythonのonelinerにあった
(n & 0o77)
はANDI 77
として、
+64
に該当するコードがないような…
この辺はハードの仕様も関わっていそう(「VRAM」に直書きしている)なので 深く考えるのは止めておこう😓
さて、このZSTORD
がどこから呼ばれるかというと
BASIC-M6502/m6502.asm at main · microsoft/BASIC-M6502
; THE WAIT LOCATION,MASK1,MASK2 STATEMENT WAITS UNTIL THE CONTENTS
; OF LOCATION IS NONZERO WHEN XORED WITH MASK2
; AND THEN ANDED WITH MASK1. IF MASK2 IS NOT PRESENT, IT
; IS ASSUMED TO BE ZERO.
FNWAIT: JSR GETNUM
STX ANDMSK
LDXI 0
JSR CHRGOT
BEQ ZSTORDO
JSR COMBYT ;GET MASK2.
STORDO: STX EORMSK
LDYI 0
WAITER: LDADY POKER
EOR EORMSK
AND ANDMSK
BEQ WAITER
ZERRTS: RTS ;GOT A NONZERO.
WAIT命令のルーチンからぽいすな
問題のZSTORD
には
その直前に呼んでいるサブルーチン(CHRGOT)の結果によって
飛んだり飛ばなかったりするようで、
じゃあそこで何をやっているかというと
CHRGOT - microsoft/BASIC-M6502
CHRGET: INC CHRGET+7 ;INCREMENT THE WHOLE TXTPTR.
BNE CHRGOT
INC CHRGET+8
CHRGOT: LDA 60000 ;A LOAD WITH AN EXT ADDR.
TXTPTR= CHRGOT+1
CMPI " " ;SKIP SPACES.
BEQ CHRGET
QNUM: CMPI ":" ;IS IT A ":"?
BCS CHRRTS ;IT IS .GE. ":"
SEC
SBCI "0" ;ALL CHARS .GT. "9" HAVE RET'D SO
SEC
SBCI 256-"0" ;SEE IF NUMERIC.
;TURN CARRY ON IF NUMERIC.
;ALSO, SETZ IF NULL.
CHRRTS: RTS ;RETURN TO CALLER.
WAIT
の直後に(スペースを挟まずに)数字が来ているかどうかを判定している(たぶん)。
ZSTORDO
に戻って
MRCHR: LDA SINCON+36,X
で参照している
SINCON+36
になにがあるかというと
SINCON -· microsoft/BASIC-M6502
IFN ADDPRC,<
SINCON: 5 ;DEGREE-1.
204 ; -14.381383816
346
032
055
033
206 ; 42.07777095
050
007
373
370
207 ; -76.704133676
231
150
211
001
207 ; 81.605223690
043
065
337
341
206 ; -41.34170209
245
135
347
050
203 ; 6.2831853070
111
017
332
242
241 ; 7.2362932E7 ←SINCON+36(8)
124
106
217
23
217 ; 73276.2515
122
103
211
315>
はい。問題の文字列(バイト列)でした😄
- Bill Gates’ Personal Easter Eggs in 8 Bit BASIC – pagetable.com
- mist64/msbasic: Microsoft BASIC for 6502 (Commodore, Apple, KIM-1, AIM-65, OSI, …)
- List of Easter eggs in Microsoft products - Wikipedia
- ビル・ゲイツがひそかに仕込んでいたイースターエッグが本人の知らない間に削除されていた - GIGAZINE
- Commodore BASIC - Wikipedia
新刊近刊
2025-10-03 | Think Stats 第3版 |
2025-10-10 | Python実践 データ分析 100本ノック 第3版 |
2025-10-22 | データサイエンスのためのソフトウェアエンジニアリング入門 |
2025-11-04 | 30秒でわかる! データサイエンスで重要な50の理論 |
Oh!X
コンピュータ専門誌「Oh!X」の令和版が2026年3月20日発売 X68000 Z対応ソフト「ネメシス’90改」の収録が決定! https://t.co/DuRyIDHVpE #SBクリエイティブ #X68000 #ネメシス90改 pic.twitter.com/86LFHYrDlt
— GAME Watch (@game_watch) September 5, 2025
値段が値段だしスルーかなあと思ってたけど 付録DVDの内容が気になる😓
awk
gawk
あれ、 gawk.git - gawk このブランチ前からあったっけ? gawk.git - gawk は知っていたけど。
ここgawk.git - gawk で分岐かな?
FORTRAN Compiler on IBM 704
- The arithmetic translator-compiler of the IBM FORTRAN automatic coding system | Communications of the ACM
- Assembly listing of transcription - Software Preservation Group
- FORTRAN II
Hugoメモ
スペイザー
#昭和50年のツイート
— ノリ (@o5kjH8uG8NGe2xK) August 29, 2025
え?合体しないの?💦#UFOロボグレンダイザー #goldoerak pic.twitter.com/TLKALXORfJ
ぜんぜん記憶に残ってなかった>最初は合体しなかった
欲しいもの
いま一番ほしいものは何かを聞かれたら、「どれだけ歳をとっても老眼にならずに、どんな本の小さな文字でもハッキリと見え続ける視力がほしいです!」と答えます。
— tak@本好き (@tak26848947) September 2, 2025
名前
社内のAIまわりを扱う部会の名前を決めようという話になっていたところ「『シンギュラリ亭』とかで良いんじゃない?」と放言していたら本当にそうなってしまった
— Windymelt🚀❤️🔥 (@windymelt) September 5, 2025
新番組
■情報解禁■
— テレビ朝日宣伝部 (@tv_asahi_PR) September 6, 2025
伝説の特撮ドラマが帰ってくる!✨
/
令和の『赤影』、参上!🟥🥷
\
《総監督》#三池崇史
《主演》#佐藤大樹(#EXILE/#FANTASTICS)
戦国歴史ロマン✖️VFX超巨大怪獣バトル
新時代の #忍者ヒーロー が誕生します⚔️
10月26日スタート!
『#仮面の忍者赤影』
📺毎週日曜深夜0:10~ pic.twitter.com/ov6u01g9E5
?!