185k views
3 votes
Generate an integer result as close as possible that solves the following straight-line equation for y. Generate an integer result as close as possible to the actual answer. Assume variable x is always an unsigned 8-bit number

User Aenw
by
3.4k points

1 Answer

5 votes

Answer:

The code is given as follows:

MVI A, 0.68

MOV E,A

MVI D, 00h

LDA memory address

MOV C,A

LXI H, 0000h

DAD D

DCR C

JNZ repeat addition

MOV, A, L

MVI B, 12h ---- give b=12

ADD B

HLT

Explanation:

The steps of algorithm are as follows

Multiplication is done using addition of same value to itself m times so

for the product m*x, add 'm' to itself 'x' times.

Then add the result to 'b'

Steps are as follows

  1. Start
  2. Get the slope value 'm'
  3. Initialise a counter with 'x'
  4. Clear a register
  5. Add 'm' to the register
  6. Decrement counter 'x'
  7. If zero, go ahead.... if not zero repeat addition
  8. Add 'd' to the product.

In the code the values are assumed as m=0.68 and b=12

User Gay
by
3.3k points