views:

335

answers:

4

Hi,

A friend of mine was given 8080 assembly code as part of a puzzle he's trying to solve. This is the code:

3E 02
4F
C6 04
47
11 41 01
21 69 00
19
76

He needs the values of B, DE, C and HL

Can anyone solve this or point me in the right direction on how to run this?

Thx!

Update

Spoiler: The solution seems to be: C = 02, B = 06, D = 01, E = 41, H = 01, L = AA

+2  A: 

Here's a guide to the 8080 instruction set: http://www.comsci.us/cpu/8080/isindex.html Your hex listing looks like an instruction stream; you should be able to go from there. How delightfully old-school!

Good luck.

quixoto
A: 

You don't need to run it - you just need to translate it. A table of 8080 opcodes like this, 10 minutes work and you will have disassembled the code. You can then simulate it mentally to work out the answer.

anon
+1  A: 

Judging by this, your best bet would be to do a search for an 8080 emulator and run it against the emulator, and get the answer from it.

Hope this helps, Best regards, Tom.

tommieb75
Unless, of course, his "friend" will be expected to do this manually, say, on a test, some time in the future. =)
David Lively
I would personally scream at any professor who would require something like this for a test.
BlueRaja - Danny Pflughoeft
@David: Good luck to memorizing the opcodes.... :) lol so cruel if that's to be expected...
tommieb75
Actually, I used to know most of the Z80 (and so also 8080) opcodes in hex by heart - I never sat down and learned them, but months hunched over an assembler and debugger engrained them in my mind. Almost all gone now, of course.
anon
@tommie I worked intimately with 8051s back in the day and accidentally memorized many, many opcodes. When I was in undergrad we had to hand disassemble machine code on an exam, but we had a 68hc11 reference manual that happily listed opcodes, flags, parameters, etc. Insert shudder here.
David Lively
+1  A: 

You need to disassemble it.

That is, convert the hex op codes in to their mnemonics.

Here's an example reference.

You can see from this that 3E is "MVI A, d8", so that looks like 3E 02 is putting the value 02 in to the A register.

Once you've decoded the mnemonics, you can look up what they actually mean and figure out the program.

Easy enough to do by hand.

Will Hartung