Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. GPT-6 Sol and Luna(openai.com)
    535comments
  2. Claude Opus 5.5(anthropic.com)
    744comments
  3. Microsoft killed FoxPro in 2007. Anyway, here's FoxPro revived(foxscript.org)
    73comments
  4. OpenAI GPT–6 Astra breaks Enigma message that has resisted solution since 2005(cryptocellar.org)
    350comments
  5. 'We hacked the FBI:' Hackers say they have data on all FBI employees(404media.co)
    181comments
  6. SAML: A fractal of bad design(trailofbits.com)
    60comments
  7. Claude Opus 5.5 Intelligence, Performance and Price Analysis (Max)(artificialanalysis.ai)
    55comments
  8. WordPress: Unauthenticated path traversal leading to conditional RCE(github.com/wordpress)
    72comments
  9. Unreal Agent(unreallabs.ai)
    59comments
  10. ReBarUEFI: Resizable BAR for almost any UEFI system(github.com/xcuri0)
    discuss
  11. An update on how we confirm your age group on Discord(discord.com)
    34comments
  12. Native apps written in TypeScript and CSS(github.com/geastack)
    16comments
  13. How did AMD Ryzen get 50% faster in two years?(lemire.me)
    48comments
  14. Did OpenAI solve the wrong Navier-Stokes problem?(scientificamerican.com)
    34comments
  15. MUNI Heritage Weekend in San Francisco(lawrence.lu)
    35comments
  16. The UV index is not the warm sensation of sunlight on bare skin(asciitweezers.com)
    34comments
  17. Markdown in /src(htmx.org)
    31comments
  18. OpenAI is well positioned to fast-follow Jev(arcturus-labs.com)
    178comments
  19. Show HN: JevBench, a reproducible benchmark for typed decision models(benchmarkheaven.com)
    7comments
  20. The trouble with 'ntile()'(djnavarro.net)
    discuss
  21. Show HN: Training a model to identify AI web content from structure alone(arxiv.org)
    8comments
  22. George Lucas Returns to Earth, Bearing Gifts(commonedge.org)
    29comments
  23. 16-bit Intel 8088 chip (c. 1985)(allpoetry.com)
    13comments
  24. Rabbit Hole: Minimum L-seams(fractalkitty.com)
    5comments
  25. People hooked on vapes try a new way to quit: cigarettes(bloomberg.com)
    65comments
  26. Pentagon says overreliance on AI contributed to missile strike on Iran school(bloomberg.com)
    160comments
  27. Apple has added persistent 'ads' to iOS, and it's driving users crazy(techradar.com)
    426comments
  28. There's a high chance of devices being sold with GrapheneOS preinstalled in 2027(grapheneos.social)
    103comments
  29. Launch HN: Coverage Cat (YC S22) – Umbrella insurance via your personal agent(coveragecat.com)
    19comments
  30. The JavaScript Midlife Crisis(maroun-baydoun.com)
    7comments

Show HN: Tetris, but the blocks are ARM instructions that execute in the browser

472 pointsby 3y agoofrak.com
53 comments
OFRAK Tetris is a project I started at work about two weeks ago. It's a web-based game that works on desktop and mobile. I made it for my company to bring to events like DEF CON, and to promote our binary analysis and patching framework called OFRAK.

In the game, 32-bit, little-endian ARM assembly instructions fall, and you can modify the operands before executing them on a CPU emulator. There are two segments mapped – one for instructions, and one for data (though both have read, write, and execute permissions). Your score is a four byte signed integer stored at the virtual address pointed to by the R12 register, and the goal is to use the instructions that fall to make the score value in memory as high as possible. When it's game over, you can download your game as an ELF to relive the glory in GDB on your favorite ARM device.

The CPU emulator is a version of Unicorn (https://www.unicorn-engine.org/) that has been cross-compiled to WebAssembly (https://alexaltea.github.io/unicorn.js/), so everything on the page runs in the browser without the need for any complicated infrastructure on the back end.

Since I've only been working on this for a short period of time leading up to its debut at DEF CON, there are still many more features I'd eventually like to implement. These include adding support for other ISAs besides ARM, adding an instruction reference manual, and lots of little cleanups, bug fixes, and adjustments.

My highest score is 509,644,979, but my average is about 131,378.

I look forward to feedback, bug reports, feature requests, and strategy discussions!

3y agoHN ↗

This is really cool! So far I have a high score of 65612 :)

Some feedback:

- When opening the help menu, it wasn't obvious how to close it (I think the only way is by pressing '?')

- I like the Goblin music!

- It's a pretty nice interface to play with the instructions and I appreciate the color coding. It would be neat if there was a "sandbox mode" where you could preview the effects of running an instruction, and maybe modify your program once the game is over. I could see this being pretty useful for someone learning ARM assembly.

3y agoHN ↗

I like the idea of sandbox mode!

I'm definitely much quicker at reading ARM assembly after playing a few hours of this game over the course of making it.

3y agoHN ↗

I'm computer literate (and know some basic assembly) but wow I did not get it

3y agoHN ↗

Hey, any specific questions? I'd be happy to explain anything that needs clarification.

More broadly, any thoughts on how to make the game clearer? I know that a manual describing the instructions would help. But other ideas are welcome as well!

3y agoHN ↗

Maybe a way to break down a game after it happened, or maybe a sandbox mode to try arbitrary things

3y agoHN ↗

I don't understand what "rotate the instruction order" keys do. I tried pressing them in many circumstances and nothing happens

3y agoHN ↗

Yeah, I may have sacrificed clarity for concision in this case.

To answer by way of example, if you are given "add R1, R2, R3" rotating to the right will result in "add R2, R3, R4". As another example, rotating "mov LR, R0" to the left will give "mov R12, SP".

In other words, rotating right changes every register RN in the instruction to be the register R(N + 1). Left changes RN to R(N - 1).

My hope was that if it was not clear from reading, it would be after testing things out. But hearing that this may not be the case is helpful feedback!

3y agoHN ↗

Oh, my bad, I misread your question.

See a reply to your original comment: it changes the order for gadgets larger than one instruction. The default is one, but originally it was three, so the instructions stuck.

I will make those confusing instructions only show up when the gadget size is greater than one! This feels like a good change to make based on this feedback.

3y agoHN ↗

Just figured it out. If you select "Adjust Difficulty" and increase the max gadget size (number of instructions that can fall at once) you change their order with these keys.

P.S. thank you for nerd sniping me with this game, I love the idea and execution (pun slightly intended)!

3y agoHN ↗

Thanks for the kind words! This comment helped me realize that I had misunderstood the parent commenter's question.

I have just pushed an update so that the up/down arrow keys only show up in the instructions if the max gadget size is greater than one.

3y agoHN ↗

i code frontend and backend web apps in javascript and typescript, very comfy with cloud stufd

but oh boy these assembly stuff these are heiroglyphs to me haha

3y agoHN ↗

You could add a puzzle mode with a fixed set of instructions introducing gameplay elements like rotate after a few puzzles to make it easier and more interesting to learn the game. My first play, I got a lot of sub instructions and my registers had all zero value. It was somehow partly pointless: Should I rotate and do sub R1, R2, R3 or do sub R2, R3, R4 to get a nop somewhere ? ;) XD

3y agoHN ↗

yeah... wanted to leave a comment I dig the aesthetics.

3y agoHN ↗

It also works with USB gamepads!

At DEF CON where we will have this set up in-person tomorrow, we will have people playing on a USB Dance Dance Revolution floor pad.

3y agoHN ↗

Cool! Does that use the Gamepad API or WebHID? I'd like to get one working in the browser for one of my projects

3y agoHN ↗

Uses the Gamepad API. I found it very easy to work with, in large part thanks to the corresponding MDN docs.

The only weird part about the Gamepad API is that you have to poll it rather than handling events the way you normally would for other, similar stuff in JavaScript. In practice, this means that you have to do your own debouncing for handling things like key combos, but that doesn't really affect individual button presses too much.

3y agoHN ↗

What an amazing idea.

Another thing to make the entry easier: Create a "Memory" label for the memory area. You mention it in the intro text but color it in the R12 address color which was confusing for me.

Missed that memory space totally while playing the first two times.

3y agoHN ↗

ASM years ago. MOV'ing without any initial data feels unnerving. WASM and JupyterLite would be cool, too.

Category:Instruction_set_listings has x86 but no aarch64: https://en.wikipedia.org/wiki/Category:Instruction_set_listi...

/? jupyter asm [kernel]:

- "Introduction to Assembly Language Tutorial.ipynb" w/ the emu86 jupyter kernel which shows register state after ops: https://github.com/gcallah/Emu86/blob/master/kernels/Introdu...

- it looks like emu86 already also supports RISC, MIPS, and WASM but not yet ARM: https://github.com/gcallah/Emu86/blob/master/assembler/WASM/...

- DeepHorizons/iarm: https://github.com/DeepHorizons/iarm/blob/master/iarm_kernel... https://github.com/DeepHorizons/iarm/blob/master/iarm/arm_in... MOV https://github.com/DeepHorizons/iarm/blob/master/tests/iarm/... :

IArm is an ARM interpreter for the ARMv6 THUMB instruction set (More specifically for the ARM Cortex M0+ CPU). It supports almost 100% of the instructions, and some assembler directives. There is also its Jupyter kernel counterpart so it can be used with Jupyter notebooks.

- JupyterLite > Adding other kernels; emu86, iarm, WASM, : https://jupyterlite.readthedocs.io/en/latest/howto/configure... [... https://github.com/jupyterlite/jupyterlite/discussions/968#d... ]

"Ask HN: How did you learn x86-64 assembly?" (2020) re: HLA, : https://news.ycombinator.com/item?id=23931373 re: the Diaphora bindiff tool and ghidra, which has GDB support now FWIU: https://news.ycombinator.com/item?id=36454485

3y agoHN ↗

As a programmer with practically 0 experience in working with assembly, this is a pretty cool tool to learn! I've been holding a cheatsheet in another tab to find out what each instruction is doing.

Kudos for building this, very cool!

edit: getting -4.8 billion as a high score because of my first segfault was... a disappointment, though. :-P

3y agoHN ↗

Before trying it I hit “About” and it opened a new page which says:

By continuing to use this site, you agree to the use of cookies.

You seem to be in violation of the GDPR. There must be a way to refuse the cookies that is as simple as accepting them. Especially since yours are not needed for the site to function:

The Services use cookies and similar technologies such as pixel tags, web beacons, clear GIFs and JavaScript (collectively, “Cookies”) to enable our servers to recognize your web browser, tell us how and when you visit and use our Services, analyze trends, learn about our user base and operate and improve our Services. (…) We may also supplement the information we collect from you with information received from third parties, including third parties that have placed their own Cookies on your device(s).

https://ofrak.com/privacy/#tracking-tools-and-opt-out

Telling people to delete cookies via their browser settings (further down that page) is not an acceptable solution.

3y agoHN ↗

Not sure if it's an error from using autocorrect, but you probably want to use complying instead of complaining.

3y agoHN ↗

Telling site visitors to disable cookies via their browser is precisely how apple.com does it.

3y agoHN ↗

GDPR doesn't care about cookies. It depends on what they're used for. If they're not used for tracking or storing personal information, GDPR doesn't apply.

It's easy to read the original comment as if you need to ask permission for any cookie usage. But that's not what they're saying. They're saying it applies for this site's cookies, as the site specify they use cookies in a way that GDPR would say you need consent for.

3y agoHN ↗

It's not even storing anything illegal on my end, only the game settings, so I don't know why it shows that banner.

3y agoHN ↗

Very cool concept, but my assembly understanding is really poor :)

It says that my score is stored in R12, but then why do I have a score of 16 of R12 is zero?

https://imgur.com/a/RY5jhTu

3y agoHN ↗

R12 contains the address of your score. In this case, that is address 0 - the start of the data segment.

The score register is yellow, and the corresponding memory region it points to (the actual bytes of your score) are also yellow.

3y agoHN ↗

Thank you, it makes sense now.

If you'd like to do a video tutorial how to play this well that could be a great resource to learn assembly intuitively.

3y agoHN ↗

This is so clever, I couldn't help but smile when I saw "Your score is stored in memory at the address pointed to by R12" :)

Thanks for sharing, it does makes me miss DEFCON, maybe next year...

3y agoHN ↗

Is the reason for R12 making you smile something you could share?

3y agoHN ↗

It's the fact that the score is handled within the game mechanics itself – so the way to get a high score is not just to play but to play with the goal of modifying R12 (so it points to a high value)

They could have easily made score be handled outside the game and you get a point per every executed statement within the time limit etc – but that would not be as fun

3y agoHN ↗

Your score is stored in memory at the address pointed to by R12

As someone who has very little idea of what instructions or addresses are, what is this a reference to?

Edit: I had the page loaded before your reply, so I didn't see it until I replied, reloading the page lol

3y agoHN ↗

It's not a reference, it's just a really neat game mechanic. Normally the high score is guarded by the game and changes only if the game deems it fit to change it. In this game, because the high score is accessible within the game and you can execute arbitrary instructions, you can use that to modify the high score.

It's as if in a more normal game the high score was kept in a big chest somewhere in the game world and once discovered you can start messing with the contents of it all within the rules of the world itself.

3y agoHN ↗

Showing the next instruction would be helpful.

3y agoHN ↗

So far, I've used two good strategies:

- Spray PC into as many registers as possible, try to add those registers together as many times as possible, and store the sum at zero (or wherever the score ends up)

- Load an assembled instruction from an old value of PC as an int into a register, then do some subtraction to make it non-negative (since it's usually negative in my experience), then store in the score location

I'm curious what other strategies people have tried?

3y agoHN ↗

I've had a lot of success segfaulting the game, as I don't know any assembly.

3y agoHN ↗

I really like the concept!

The key to achieve high scores seems to be writing 0 to PC. The reason is the binary code of new instructions will be "added" to the memory region that is visible on the right, then we can manipulate R12 to maximize the score.

3y agoHN ↗

Ah, another key is to change R12 to a number that is not divisible by 4. This is because every instruction is 4 bytes and the most significant bit is always 1.

I got around 2 billon a couple of times but the average is quite low ;)

3y agoHN ↗

Trying to figure it out, I got 552 Million :)

Great concept! I'm afraid to show it to my team of C++ developers bc they might be tempted to switch over to doing everything in Assembly :)

3y agoHN ↗

omg, this is awesome. i’d been meaning to pick up some ARM assembly. and the fact that you managed to link game mechanics with working opcodes is great.

love it!

3y agoHN ↗

Very interesting game! Do you have any plans to make the RISC-V version? Thank you for sharing this game!