nomemory / andreinc-site

My personal blog
10 stars 4 forks source link

2021/12/01/writing-a-simple-vm-in-less-than-125-lines-of-c #5

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Writing a simple 16 bit VM in less than 125 lines of C | andreinc

Writing a simple VM for LC3 in less than 125 lines of C

https://www.andreinc.net/2021/12/01/writing-a-simple-vm-in-less-than-125-lines-of-c

wjmcdermott commented 2 years ago

This is amazing! Greeting from Australia. Thanks very much for sharing this and I hope you have a safe and happy Christmas.

bobertyy commented 2 years ago

Hey! Quick heads up - the link to the repo has a random comma in (https://github.com/,nomemory/lc3-vm). I enjoyed the article, good work!

cosmadragos73 commented 2 years ago

interesting read

drbos commented 2 years ago

A very interesting concept, but i found a few minor problems in trying to follow it on a Linux system.

gcc simple_prog.c ./a.out gcc vm.c vm_dbg.c ./a.out simple_prog.obj

RapidCodeLab commented 2 years ago

wow, i read this in one breath )

carueda commented 2 years ago

Great educational resource (and timely as I'm helping my son learn C, including pointer/memory operations and the like). Thanks for putting it together!

shantanu-gontia commented 2 years ago

Amazing article. Very instructional.

Just wanted to point out there's a few typos, there's some add's in the and section.

kbdyj1 commented 2 years ago

very helpful to me. thanks !!!

GuoshunWu commented 2 years ago

Amazing, I never saw such neat and practical article for this topic. It's taught me a lot.

andutei commented 11 months ago

A better sign extend would be: int s = 16 - b; return (int16_t) n << s >> s; The cast to int makes the right shift an arithmetic right shift. Or you can just declare n as int16_t in the function arguments.

Gbemiro8 commented 11 months ago

Great amazing article Nit just some typo in the OPC op_ex[OP(instr)](instr) should be op_ex[OPC(instr)](instr)

MichelMoriniaux commented 10 months ago

Thanks so much for this article that took me back 30 years ago to my first assignment on my first semester of CS eng school: Corewar: write a VM and an agent and try to beat the other students. That one assignment built all the solid bases I needed to start my journey. I'm amazed that students today are not exposed to this.