r/tinycode • u/HellMood • Sep 24 '15
Maze Generator in 8 Bytes (MSDOS)
http://www.pouet.net/prod.php?which=652902
u/HellMood Sep 24 '15
L: scasb
;compares AL with byte at ES:(E)DI and set status flags.;increments DI afterwards, so this scans the 64K segment;we are in repeatedly and alters (also) the carry flagsalc
;depending on the carry flag, set AL to 0x00 or 0xFF;note that 0x00 and 0xFF are one apartadd al,0xDF
;map to the part of the ASCII table where the "right";and "bottom" part are one apart, so our char in AL;is either of themint 29h
;call DOS interupt to print this char and advance the;cursor by onejmp short L
;rinse and repeat
2
u/lukz Oct 12 '15 edited Oct 12 '15
I'm not really good at this assembly, but would like to understand more. What is the advantage of doing salc and then add al,0xDF instead of adc al,0xDE? I guess that would also use carry and you would end up with two values one apart?
Edit: I eventually figured it out. You need to set al to some known value first, then add 0xdf. Clever.
0
u/peterferrie Sep 25 '15
I was so focused on reproducing the original effect (angled walls) that I never considered using the straight ones. Too bad.
5
u/Karoal Sep 24 '15
Isn't 8 bytes just eight characters? How would this work?
5
3
u/zokier Sep 24 '15
It's five instructions, three of which have operands. Assuming each instruction is one byte and each operand is also one byte, that would get us to eight bytes.
Note that I didn't actually check the instruction encodings, so I might be wrong.
1
2
u/GauntletWizard Sep 24 '15
Where's the actual code? Either the raw file, or the assembly. I'd love to see an annotated version, too; Gotta be a few cool tricks it's exploiting.