On 4/2/2006 at 8:30 PM Jim Battle wrote:
One question posed on this list not all that long ago
was: what is the
shortest program that you can run on an 8080 where the program will zero
all memory, including itself. or something like that. The puzzle is
probably equally interesting on many other cpus.
I've heard of people asking these types of questions during job
interviews -- and I think it is an asinine way of judging someone's
abilities.
I disagree. Consider that, as a manager, you might be looking at a whole
herd of people who have perfect university transcripts and impressive
resum?s. That mostly tells me that (A) they knew how to be students and
take tests and (B) had a very talented writer for their resum?s. Neither
tells me anything about their on-the-job capabilities and more importantly,
their ability to program. And I've interviewd enough people who can lay
down an impressive line of BS.
One of the peculiar aspects of assembly language programming is the ability
to hold the details of what each and every instruction does and how to
apply that knowledge. So, yes, the problem posed by the CDC problem
involves instinctively knowing that there's no way to store a register
without clobbering another one. However, the "aha" is knowing that the RJ
(return jump) instruction uses no registers but it does modify memory. So
you write a list instructions that conditionally jump on the sign bit of a
B register around a return jump that records whether the jump for that bit
was taken, followed by an add-to-self to shift the B register left by one
bit.
An assembly language programmer that doesn't have the dscipline to know his
instruction sets in detail and use that knowledge either writes horribly
bloated code or spends inordinate amounts of time because, for instance, he
doesn't realize that the 16-bit increment instructions on the 8080 don't
modify any condition codes or that the 8 bit increments don't modify the
carry bit.
Getting an indication of this right off the bat is much easier than trying
to figure out (A) where am I going to find another programmer to do what
this guy was hired to do and (B) how am I going to fire the current guy
without him filing a dispute with the state department of labor.
Cheers,
Chuck