I am Andrey

Back to Introduce Yourself forum

GlideThestral     2015-11-03 07:10:39

Hello, I'm Andrey, welsh corgi cardigan dogs breeder from Moscow. Currently we have three beautiful corgy girls, 7, 4 and 1 years old.

I've started programming exactly 30 years ago, as a student. First language was Fortran, then PDP 11/70 assembly, C, Z80,... Now I stay on C#. Like to solve mathematical puzzles, especially if they have programming parts.

Rodion (admin)     2015-11-03 07:45:16
User avatar

Andrey, hello!

Is this the breed you are speaking of?

Welsh Corgi Cardigan

They look quite funny and cute - though I believe I never seen one in surrounding, when I walk with my zwergschnauzer - they seems to be rare! :)

>First language was Fortran, then PDP 11/70 assembly, C, Z80

Wow... I feel somewhat envious :) I wish I have some time to reanimate my ZX - once bought at "barakholka" just for amusement... It was working until I get rid of TV...

And by the way you seemed to make a hit / breakthrough with your BCD-to-HEX solution couple days ago - really great!

UPD I've uploaded the picture to other resource - excuse me for poor link at first...

GlideThestral     2015-11-03 08:00:06

I don't see the picture, but probably it's that breed.

Yes, they are rare - I guess that there is less that 2000 cardis in Russia (I've lost count at 600). But not as rare as Sweedish Valhund - there are only 10 of them :)

With fixed DAA instruction problem BCD-to-HEX is even easier. It could be fun to optimize number of processor cycles (with restricted size of program) in some challenge...

Quandray     2015-11-03 09:53:13
User avatar

Hi Andrey,

Well done on your 27 byte solution to BCD to Hex. I thought my 37 byte solution was good, but it was more fast than small. I had to do it a different way, that was much slower, to get it smaller. I'm now on 29 bytes and aiming at 27. It's much easier to aim at something I know is possible. I just need to see if my code needs a tweak or whether I need to find another different way.

I guess I'm the person on here who lives the closest to Cardigan. I'm about 120k away. It's interesting to hear that the corgis are so popular in Russia.

GlideThestral     2015-11-03 10:33:09

Looks like without "0 0 0 0" test we could save two more bytes.

GlideThestral     2015-11-03 10:53:28

Waiting for the next move :P

Quandray     2015-11-03 11:08:18
User avatar

Don't hold your breath :-)

Rodion (admin)     2015-11-03 12:14:38
User avatar

>It could be fun to optimize number of processor cycles

At first I thought it is complicated - but now I read the documentation and it says only that for this CPU every instruction takes just as many cycles as many bytes.

So I think it would not be hard to update the code of emulator... Have you - or perhaps Quandray any preference of the idea for the challenge?

GlideThestral     2015-11-03 12:31:28

One step of "Game of Life" on 4x6 field (R0:R5)? But it may be too long program...

Alternative is unsigned division (hexadecimal) of R3:R0 by R5:R4. And you can use sum of cycle numbers for 10 secret tests as a result.

Quandray     2015-11-03 13:32:51
User avatar

There's always an exception and maybe you haven't implemented FIN yet but "Although FIN is a 1-word instruction, its execution requires two memory cycles (21.6 psec)"

GlideThestral     2015-11-03 14:16:31

My youngest girl, Belka:

Belka

GlideThestral     2015-11-03 17:01:46

Okay, so I'll go ahead myself...

25 is "fast" solution :)

Quandray     2015-11-03 17:08:43
User avatar

Well done. I'm still stuck on 27 :-)

Rodion (admin)     2015-11-04 05:25:40
User avatar

I think I should show this picture to my wife - she usually is extremely fond of small dogs :) I hope they have a nice temper...

To Quandray we have the FIN instruction though with some cheat, so it could not access instruction bytes. Anyway it is used in Hello World Example so thank you for pointing this out.

I'll try to think a bit about those ideas - on Game-of-Life step or division, or something else... Hope to come back with something soon!

GlideThestral     2015-11-04 06:47:57

One more idea - about work with memory: to sort array of type byte[16]. Limit for program size may be 255 bytes (I hope it's enough for the simplest algorithm).

Rodion (admin)     2015-11-04 12:27:20
User avatar

As a matter of fact our RAM contains 256 nibbles so we can try to sort more...

I've just finished implementation of Life game in 8*8 field. It is about 200 bytes long and takes about 18000 cycles for one step. However I found one trouble here - with different input data the amount of clock cycles also could be different of course.

So for such challenge it would not be just to use randomized input. But then we'll need to use some constant, predefined one. Should it be kept in private (to avoid perhaps tuning for this specific input) or not - what do you think?

Of course we can add two challenges - one to minimize code size (this could be done right now), another to make the fastest program (we need to discuss the question above at first). So just say if you want them!

> Limit for program size may be 255 bytes

I believe it is necessary for our emulator do not regard original CPU troubles with code memory pages, so it would be a kind of cheating to write larger programs. As I understand with Intel-4004 most jump instructions could not jump over the page boundary, for example. I believe programmers of MCS-4 system have a lot of headache because of such limitations...

P.S. I've updated emulator on site also so it shows clock cycles after execution, so we can experiment with codes...

GlideThestral     2015-11-04 14:09:31

8x8 field - with one cell per bit or per 4 bits?

I think that input should be secret. And that there may be more than one input field (and result is the sum of cycle counts).

Rodion (admin)     2015-11-04 14:44:57
User avatar

I used RAM to store the field and input from our "console" (as in Prn Hex Str) for input and output. The field has topology of torus - i.e. its edges are glued so we avoid border effects.

So we can use some predefined secret input, (generated beforehand and hardcoded into checker as random mess of cells).

Will this be Ok?

We can use even larger field of 16x16 (as we have 256 nibbles of memory), but I think it would be nice to have input/output not very large...

GlideThestral     2015-11-04 16:22:59

So input and output are - line of 64 binary digits or 8 lines of 8? And all users will get the same time penalty required for I/O operations. Looks good.

Rodionische     2015-11-04 19:46:30
User avatar

I just finished creating the problem - and tried to submit my solution. Please feel free to report if any bugs are suspected!
(it's me, admin again)

GlideThestral     2015-11-04 20:16:50

Yes, it works. I'll play with cycles count later, during optimization of my solution.

Rodion (admin)     2015-11-04 20:28:40
User avatar

Wow... It looks like my test-solution is extremely inefficient... 17777 cycles

UPD: Managed to save more than half - less than 7000 now but still far from your result!

Moff     2015-11-05 13:53:01
User avatar

Hi Andrey! I'm impressed Your results at assembly: 25 bytes - it's a kind of magic (for me)! I think it's an old-school experience.

GlideThestral     2015-11-05 15:30:33

Hi Sergey! Actually I didn't met 4004 before. But some tricks from Z80 and from operations with long numbers in 8086 work here well enough

GlideThestral     2015-11-06 10:39:44

A+B in 4004 - terrible problem... Even with non-negative A,B

Rodion (admin)     2015-11-06 11:18:46
User avatar

Ha-ha, I just thought yesterday that someone may try it as a form of joke - and here you are! :)

GlideThestral     2015-11-06 11:42:02

Well, there is also such thing as pure Brainf@ck for this problem...

What do you think about Turing Machine as one more language?

Rodion (admin)     2015-11-06 20:12:32
User avatar

I think it would be great if only we can come up with such specification/version of Turing Machine which will allow to create enough funny problems. If you have some ideas of this kind - I believe I'll be ready to implement them!

As it happened with BF mentioned above - after solving few tasks it started looking dull because of the programs consisted of mainly similar blocks.

Among nearest plans there was idea to implement some newer assembly... The main question is about how to make less buggy and clumsy emulator :)

P.S. I remember when in school I once created 2D Turing Machine - but the only program I invented for it was for travelling through simple maze...

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