• Welcome to Valhalla Legends Archive.
 

ASM riddle I had in a contest 2 years ago

Started by Yoni, February 11, 2003, 12:39 PM

Previous topic - Next topic

Yoni

This is x86, 16-bit, under DOS.
0100 B50D         mov ch, 0d
0102 BD29D2       mov bp, d229
0105 8BF9         mov di, cx
0107 51           push cx
0108 AD           lodsw
0109 F7F5         div bp
010B AB           stosw
010C E2FA         loop 0108
010E 5E           pop si
010F 8BCE         mov cx, si
0111 FF04         inc word ptr [si]
0113 4D           dec bp
0114 75ED         jnz 0103
0116 AD           lodsw
0117 B310         mov bl, 10
0119 D1C0         rol ax, 1
011B 50           push ax
011C 2401         and al, 01
011E 0430         add al, 30
0120 CD29         int 29
0122 58           pop ax
0123 4B           dec bx
0124 75F3         jnz 0119
0126 E2EE         loop 0116
0128 C3           ret
Note: Under DOS, interrupt 29 prints the ASCII char in the AL register. The rest of it should be platform independent.

Try to run it (in debug.exe or using whatever other method).
The riddle is: What is the meaning of its output?

Before someone "corrects" me: Yes, the instruction at address 0114 is correct.

Enjoy.

Yoni

#1
Solved [Adron].
Anyone else? :)

n00blar

#2
Would I be correct in saying D2 is a rotate instruction? I can't remember????

Yoni

#3
Use an assembler or a x86 reference to check.