RevSoft Code Game
Posted: Sun 30 Jul, 2006 11:27 am
We had a code game over at RevSoft, but we ran out of ideas after a while and it became a routine contest. So since some of you don't drop by RevSoft that often, I'll post the question here so you can play. Most of it is finding the most optimised way in z80 code, others are knowledge of the cpu.
Don't cheat, I'll know if your cheating because I know who knows the answers and who doesn't. And be careful, some things that seem obvious or well known are not correct.
Last the questions are in no particular order, difficulty will vary as you progress.
Question 01 - Spencer's:
Turn an 8-bit signed number into a 16-bit signed number. You do this by propagating the sign bit all the way to the most significant bit.
%10110110 turns to %1111111110110110,
%00000001 turns to %0000000000000001
Question 02 - Jim e's:
How many bytes is this, ANSWER WITH OUT LOOKING AT GUIDES!!! Also tell why your answer is correct!
Question 03 - NanoWar's:
Will the hex value be A, B, C, D or E?
A. 18 FE
B. 18 FF
C. 18 00
D. 18 01
E. 18 02
Question 04 - Jim e's:
okay here is an easy one I expect everyone to get it.
Relative to C what does A contain at the end of this code.
Hint: its an equation I don't expect an exact number.
Question 05 - Jim e's:
Name the registers in the CPU. If they can be paired, name them by their pairs. DO IT FROM MEMORY!
Question 06 - Jim e's:
Super duper easy!
add hl,de
P/V flags detects Parity or overflow, Do it from memory.
Question 07 - KevinJB's:
Here's an easy one:
What in order does sram, sram + 1, sram + 2, and sram + 3 hold?
Question 08 - Jim e's: ( altered from the original )
Reverse the bits of C and place it into A. So %10100000 would be come %00000101
Do this without the RLA or RRA instruction.
FASTEST CODE WINS.
Question 09 - Stickmanofdoom's:
Write a routine that will add A to DE (unsigned) without an "add reg16,reg16" instruction like "add hl,de".
I've posted something about this before, but I can't come up with anything else that would fit this game.
Editor Jim e's Note: Speed determines winner, since probability may play a role in this, post multiple answers.
Question 10 - KevinJB's:
Explain each bit in the Flag register. Sound good?
That's the end of the quiz. I'll post the answers later, most of it is simple. Some of it is pretty tough. Feel free to post your own quiz questions.
To be nice Hide you answers when you post them, The board color is #cfcfbf, So to hide text it would be.
Hidden Text
Hidden Text
I really want to see MC's brightest participate in this. Because even Spencer only got one correct. Haha, burned him while he is on vacation.
(Gratuitous blank space to reduce answer spoilage.)
Don't cheat, I'll know if your cheating because I know who knows the answers and who doesn't. And be careful, some things that seem obvious or well known are not correct.
Last the questions are in no particular order, difficulty will vary as you progress.
Question 01 - Spencer's:
Turn an 8-bit signed number into a 16-bit signed number. You do this by propagating the sign bit all the way to the most significant bit.
%10110110 turns to %1111111110110110,
%00000001 turns to %0000000000000001
Code: Select all
inputs: a - 8-bit signed number
outputs: bc - same 16-bit signed number
Question 02 - Jim e's:
Code: Select all
ld hl,(source)
ld de,(destination)
ld bc,(length)
ldir
Question 03 - NanoWar's:
Code: Select all
label: jr label
A. 18 FE
B. 18 FF
C. 18 00
D. 18 01
E. 18 02
Question 04 - Jim e's:
okay here is an easy one I expect everyone to get it.
Code: Select all
di
ld a,r
ld c,a
ld b,a
ld hl,($8000)
ld ix,($8002)
label:
ex de,hl
add ix,de
djnz label
ld a,r
Hint: its an equation I don't expect an exact number.
Question 05 - Jim e's:
Name the registers in the CPU. If they can be paired, name them by their pairs. DO IT FROM MEMORY!
Question 06 - Jim e's:
Super duper easy!
add hl,de
P/V flags detects Parity or overflow, Do it from memory.
Question 07 - KevinJB's:
Here's an easy one:
Code: Select all
xor a
ld (sram), a
ld (sram+1), a
ld (sram+2), a
ld (sram+3), a
ld hl, 255
push hl
push hl
pop hl
ld (sram), hl
pop hl
ld (sram + 1), hl
Question 08 - Jim e's: ( altered from the original )
Reverse the bits of C and place it into A. So %10100000 would be come %00000101
Do this without the RLA or RRA instruction.
FASTEST CODE WINS.
Question 09 - Stickmanofdoom's:
Write a routine that will add A to DE (unsigned) without an "add reg16,reg16" instruction like "add hl,de".
I've posted something about this before, but I can't come up with anything else that would fit this game.
Editor Jim e's Note: Speed determines winner, since probability may play a role in this, post multiple answers.
Question 10 - KevinJB's:
Explain each bit in the Flag register. Sound good?
That's the end of the quiz. I'll post the answers later, most of it is simple. Some of it is pretty tough. Feel free to post your own quiz questions.
To be nice Hide you answers when you post them, The board color is #cfcfbf, So to hide text it would be.
Hidden Text
Hidden Text
I really want to see MC's brightest participate in this. Because even Spencer only got one correct. Haha, burned him while he is on vacation.
(Gratuitous blank space to reduce answer spoilage.)