[HN Gopher] Show HN: Turbine - 16-bit CPU Architecture and Emula...
___________________________________________________________________
Show HN: Turbine - 16-bit CPU Architecture and Emulator built in C
Github: https://github.com/errorcodezero/turbine
Author : errorcodezero
Score : 39 points
Date : 2025-06-20 03:59 UTC (3 days ago)
(HTM) web link (www.errorcodezero.dev)
(TXT) w3m dump (www.errorcodezero.dev)
| lioeters wrote:
| Fun article and project. I enjoyed reading and playing around
| with it.
|
| My first run of `make release` failed with this error.
| cc -std=c11 -Wall -Wextra -Werror -pedantic -O3 -DNDEBUG -c -o
| build/main.o src/main.c src/main.c: In function 'main':
| src/main.c:23:3: error: ignoring return value of 'fread' declared
| with attribute 'warn_unused_result' [-Werror=unused-result]
| 23 | fread(file, file_size, 1, fp); |
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being
| treated as errors
|
| It might have something to do with my local setup. It was simple
| enough to solve, to check the return value and exit with error
| code.
| johnisgood wrote:
| Yes, to fix it: either check its return value, or add "(void)"
| at the end of the function, e.g. "(void)fread(...)". Since they
| did not add "(void)", I assume they meant to check the return
| value, they just simply forgot.
| johnisgood wrote:
| s/end/beginning/
| errorcodezero wrote:
| Ah oops small mistake with the C file handling. Thank you for
| the kind words on my project and finding the issue I'll be sure
| to fix it when I get the time.
| lioeters wrote:
| The article was really good, explaining the details of how
| the virtual machine works.
|
| I starred the Git repo, good luck with the Hack Club!
| errorcodezero wrote:
| Thank you for the star. It means a lot that you found the
| stuff I make cool.
| drob518 wrote:
| Fun project. You might want to build an emulator for a real
| 16-bit CPU like a 6502. That would allow you to run real,
| existing software on it. That way you don't have to write your
| own code.
| AlexeyBrin wrote:
| 6502 is an 8-bit CPU. Writing an emulator for it would be cool
| though.
| vardump wrote:
| It's interesting how arbitrarily CPU bitness is defined.
| Sometimes it's the register size, sometimes data bus width
| and sometimes the address width.
|
| 6502 has 8 bit registers, 8 bits wide data bus, and 16 bit
| addresses. Only PC register is 16-bit, but 6502 does have a
| zero page indirect 16-bit addressing mode.
| wang_li wrote:
| Sometimes by register size, sometimes by ALU size,
| sometimes by data bus width. But I've never heard of a CPU
| bitness defined by address bus size.
| pjc50 wrote:
| M68k is probably the best choice for that. Not because of the
| architecture but because it was so widely used.
| dmitrygr wrote:
| 68k has too many addressing modes. It is a pain to emulate
| properly.
| errorcodezero wrote:
| Thank you! I think building an emulator for a real platform is
| going to be next on my list. A game console might be
| interesting to try especially or a 16-bit cpu like you
| mentioned.
___________________________________________________________________
(page generated 2025-06-23 23:02 UTC)