JS में emulator बनाना और उसे multi-UI के साथ जोड़ना
(taniarascia.com)-
1970 के दशक की 8-bit मशीनों में इस्तेमाल होने वाले Chip-8 interpreter को JS में इम्प्लीमेंट करना
-
वेब/CLI/native app के साथ इंटीग्रेशन
-
तकनीकी रूप से यह interpreter है, लेकिन emulator के ज़्यादा क़रीब है, इसलिए emulator बनाना सीखने वालों के लिए उपयुक्त है.
-
Memory(4KB), Program Counter, Register, Index Register, Stack, Stack Pointer, Timer आदि को variables के रूप में घोषित करना
CPU बनाना, और 4x4 HEX keyboard, 64x32 display को इम्प्लीमेंट करना
-
JavaScript code में Raylib Node.js binding का उपयोग करके इसे विभिन्न native environments में चलाया जा सकता है
3 टिप्पणियां
8-बिट आर्किटेक्चर होने की वजह से कोड बहुत जटिल नहीं है, इसलिए इसे पढ़ना काफ़ी मज़ेदार है।
नीचे दिया गया कोड मुझे प्रभावशाली लगा।
class CPU {
constructor() {
this.memory = new Uint8Array(4096)
this.registers = new Uint8Array(16)
this.stack = new Uint16Array(16)
this.ST = 0
this.DT = 0
this.I = 0
this.SP = -1
this.PC = 0x200
}
}
मुझे लगा था कि stack 16 bytes का होने के लिए बहुत छोटा है, लेकिन memory 4k है इसलिए यह संभव लगता है।
आह~ 16 word, 16 word