From Brainf--k to Assembly

Back to General discussions forum

Rodion (admin)     2015-01-25 07:08:15
User avatar

Friends, I'm now thinking of adding a set of problems on Assembly for Intel 4004 - the grandfather of all CPU-s.

It will work similarly to Brainf--k problems - you will need to submit the code in specific language which is then tested on server.

We already have asm-4004 emulator added to CodeAbbey - and you can see that TestUser already solved one of existing problems with it: Reverse String by TestUser. You will be also able to use emulator offline (it is written in Python and have only few small files - link to project).

Compared to BF you will need to learn about 25 commands instead of 10. On the other hand you will be able to perform more powerful operations (i.e. adding and multiplying even large numbers will not take millions of steps). I think we'll be able to learn funny algorithms for integer arithmetics and for graphics like Bresenham's line with it.

So please, if you have about 30 minutes of time, check few pages of the tutorial I wrote and watch its examples in online emulator. Then judge whether you would like such problems to be added to our site and comment your thoughts here :)

Thanks in advance for your help and advice!

P.S. this is also asked in our FaceBook page.

Christopher Matthews     2015-01-25 09:22:28

I found an in-depth instruction manual from 1973 if anybody is interested, which you can download here.

Christopher P. Matthews

Quandray     2015-01-25 14:29:17
User avatar

The tutorial is good and I think it is a great idea for a set of problems. It must be easier than BF!

TestUser     2015-01-25 20:36:46
User avatar

Hello Colleagues!

Christopher, thanks a lot! I've found two other pieces of original documentation, but completely missed this one! I regret I had no chance to study it earlier. Well, I hope I'll be able to made changes to my emulator if necessary along reading it!

I decided to collect all these documents also at dedicated project wiki page.

Graeme thanks for your kind and encouraging words. :)

I suspect you have more experience with assembly languages for some CPUs (probably of Z80 family) than any of us (or all of us, ha-ha). It is great to have your opinion for support! :)

P.S. It was me, Rodion, again from the wrong account - I was trying to find out some possible bug and forgot to switch back...

Quandray     2015-01-26 07:37:49
User avatar

Yes, I've done a fair bit of Z80 assembler and some 6502 assembler. I've also done a little bit of IBM BAL.

No difficulty with the first 4004 problem. My solution was the same as yours, apart from the comments!

Grae

Quandray     2015-01-27 16:59:14
User avatar

Hi Rodion,

Thanks, you've reminded me how much I like assembler!

In your solution for "Mul Two" you don't make any assumption about the initial state of carry and your code starts with a CLC.

However your solution for "Loops in Assembly" only works if carry is initially clear.

Grae

Rodion (admin)     2015-01-27 17:31:18
User avatar

Grae, thanks for your kind word and for this correction!

I'm glad you like these problems and help in testing them. I have plans to build another interpreter, for contemporary chips (like Atmel's) if this kind of problems will be popular enough. So I hope this would be not only piece of story :)

BTW it is the first time I've heard about IBM BAL. I feel envious to your experience! :)

sincerely yours, Rodion

Please login and solve 5 problems to be able to post at forum