Boolean
Boolean

Reputation: 17

Write 3 instructions in 1 in assembly

The following instructions are given:

add bx, 3 or 4
mov ax, si
add bx,ax

How can you write this by using only one instruction?

Upvotes: 0

Views: 69

Answers (1)

Guffa
Guffa

Reputation: 700650

Strictly speaking, you can't. There is no instruction that will do two separate calculations and put two unrelated values in the ax and bx registers.

If it's only getting the value into bx that is interesting, then it's possible. You can use the lea instruction to do the calculation in the form of a memory address, and store the value in bx:

lea bx, [bx + si + (3 or 4)]

Upvotes: 5

Related Questions