OK, there are 2 question 2's - that's confusing.

Taking the second 2, plus 3,4 in the PDF as 3,4,5 this makes more sense...

Q4:

Yep, you could use three instructions, but the question asks for the shortest possible way.

I dropped a major hint twice, see if you can spot it.

FOUR CONSECUTIVE BYTES

FOUR CONSECUTIVE BYTES

FOUR CONSECUTIVE BYTES

FOUR CONSECUTIVE BYTES

FOUR CONSECUTIVE BYTES

FOUR CONSECUTIVE BYTES

FOUR CONSECUTIVE BYTES

FOUR CONSECUTIVE BYTES

FOUR CONSECUTIVE BYTES

FOUR CONSECUTIVE BYTES

Dropped it 10 more times for you just in case you couldn't find it.

I wonder if there are any 4 byte instructions.

I wonder if we can somehow combine -2 in one byte, +1 in 2 bytes and 5 in one byte into a single four-byte constant, cos if we can, and if there are 4-byte instructions, then maybe we can solve this with a single instruction.

I wonder if the "assume" bit in brackets has anything* to do with a possible answer.

* maybe this is the answer handed to you on a silver platter.

5.1

Quote:

Adds cx-1 times the carry from bx*2

Adds the previous carry bit to DX cx times (doest change during calculation)

No. Try dry running the code. Assume some (small - to keep the simulation short) values for BX and CX. Have an 8086 reference at hand, for example

http://www.emu8086.com/assembly_lang...ction_set.html
Let's say BX, CX, DX start out at 5,4,0 respectively. You might find it helpful to write it out on paper in tabular form. This is an absolutely essential skill for programmers, by the way. I'll get you started:

Code:

Instruction AX BX CX DX
start: ?? 5 4 0
mov ax,0 0 5 4 0
add ax,bx *1 5
adc dx,0 *2 (not filled in - you must RTFM)
loop 3 CX!=0 so we loop back to the "add"
add ax,bx 10
adc dx,0 (not filled in - you must RTFM)
loop 2 CX!=0 so we loop
...

Some notes:

*1 Look this up in the documentation. What would happen if AX+BX>65535? Whatever the outcome, are you certain this doesn't affect the carry bit at all (as per your comment "Adds the previous carry bit ... (doesn't change during calculation)")?

*2 Also look this up in the documentation. What's the difference between ADD and ADC? If AX+BX<65536, what would the ADC instruction do? If AX+BX>65535, would the ADC instruction do anything different? I haven't put values under AX~DX for this instruction, deliberately, because you need to lookup ADC in TFM.

Once you've done that, do it again with a big starting value for BX - say 50,000. Use a calculator to keep track of BX.

Note: with experience you'll be able to dry run stuff in your head. Dry running on paper first is an essential first step, only when you've done that a few times will you be able to do it mentally, just like maths, there was a time you could only do moderately complicated maths on paper, e.g. 62*120, but I bet you could do that in your head now.

5.2. It's very interesting that the DX register was chosen. I wonder if there's a single instruction that does what the previous code chunk does? (That's why you have to get what it does correct). Perhaps the choice of the DX register is a clue. But if I tell you where to look in the docs then I give away what the first part does, and you need to work that out.