[HN Gopher] Avremu: An 8-Bit AVR Microcontroller Simulator Writt...
       ___________________________________________________________________
        
       Avremu: An 8-Bit AVR Microcontroller Simulator Written in LaTeX
        
       Author : nurple
       Score  : 60 points
       Date   : 2024-11-12 00:58 UTC (22 hours ago)
        
 (HTM) web link (gitlab.brokenpipe.de)
 (TXT) w3m dump (gitlab.brokenpipe.de)
        
       | dang wrote:
       | Related:
       | 
       |  _Avremu: An AVR Emulator Written in Pure LaTeX_ -
       | https://news.ycombinator.com/item?id=13126595 - Dec 2016 (29
       | comments)
       | 
       |  _Show HN: Avremu - An 8-Bit Microcontroller in Pure LaTeX_ -
       | https://news.ycombinator.com/item?id=8448322 - Oct 2014 (18
       | comments)
        
       | dang wrote:
       | (Url changed from
       | https://ctan.org/texarchive/macros/latex/contrib/avremu, which
       | points to this.)
        
       | mmastrac wrote:
       | I love whimsy.
       | 
       | > You are writing an CPU emulator in TeX, the TYPESETTING system?
       | 
       | Yep.
       | 
       | > Are you insane?
       | 
       | Not that anybody knows of.
        
       | leonheld wrote:
       | Had to read the title 3 times.
       | 
       | It's... actually readable? For example
       | https://gitlab.brokenpipe.de/stettberger/avremu/-/blob/maste...
       | hits me as a very usual pattern to write emulators.
        
         | Lerc wrote:
         | I made an AVR emulator in Haxe/JavaScript.
         | 
         | It turned out to be more awkward than I expected. Most 8-bit
         | processors have instructions fairly clearly specified in the
         | first byte. So the bulk of the decoding work can be done with a
         | small jump table. The avr is more bit packed. Due to the way I
         | progressively implemented the instructions I ended up with a
         | kind-of tree of case statements. At some stage I'd like to go
         | back and have a converter to a larger but easier to decode
         | format. Instructions being in ROM(ish) and being easy to detect
         | when updated means AOT is easy enough to do.
         | 
         | It might only need 32 bits per instruction. Opcode in the first
         | byte and then byte aligned operands.
        
       | stettberger wrote:
       | I had quite some fun implementing this at a very lovely lake in
       | Sweden, while my colleagues were attending GPCE.
        
         | jfim wrote:
         | That's absolutely hilarious, and a pretty fun hack.
         | 
         | By the way, if I understood you correctly, this sentence
         | 
         | > I'm still missing 5 opcodes (MULS, MULSU, FMUL, FMULS,
         | FMULSU), but until now I did not encounter a C file, the AVR-
         | GCC emits these opcodes.
         | 
         | could be rewritten as
         | 
         | > There are 5 opcodes that are not implemented (MULS, MULSU,
         | FMUL, FMULS, FMULSU), as I have not yet encountered a C file
         | for which AVR-GCC emits these opcodes.
        
           | couchand wrote:
           | The classic AVR instruction set does not include
           | multiplication, you have to be targeting a device that
           | supports AVRe+, such as an ATmega rather than an ATtiny. Try
           | adding -mmcu=avr5 and it will show up pretty quick. Example:
           | https://godbolt.org/z/x951M8fn8
           | 
           | Edit: nice work author, I love it!
        
       | marcodiego wrote:
       | Now, let's get that 8bit microcontroller running Linux and run
       | Linux inside a LaTeX document.
        
       | kjs3 wrote:
       | Nifty. If you're going to really nail the side-project, go weird
       | or go home. _chef kiss_
        
       | leni536 wrote:
       | I guess postscript could be an other interesting target, so you
       | could run your emulated C code on some printers.
        
       ___________________________________________________________________
       (page generated 2024-11-12 23:00 UTC)