Anonymous asked in Computers & InternetProgramming & Design · 4 weeks ago

Write a assembly program that increments by 2 the content of a register 10 times?


8 bit with two operands with the result stored in one of the input registers. if this helps

1)Write a program that adds two operands.

2)Write a program that adds operands until the new value to be added is 0.

3)Write a program that increments by 2 the content of a register 10 times.

4)Write a program that shifts the content of a register until the least significant bit is 0. stop shifting if the content of the register is 11111111

3 Answers

  • 4 weeks ago

    It's a single instruction on most CPUs:

    addi R3,20         ; Add 20 to register R3

    Of course, the opcode and register names are made up because you haven't specified what processor you're using.  Every processor family has its own instruction set.

    If you need to write a loop, that can be even more processor-specific.  For example, 8086 code to increment register AX might look like:

              mov   cx,10           ; loop count

    L1:     inc     ax                ; increment AX by 2

              inc     ax

              loop   L1                ; repeat a total of 10 times

    The same idea on IBM S/390 might be:

                L        R0,=F'10'                  LOOP COUNT

    L1        A        R1,=F'2'                    INCREMENT R1 BY 2

                BCT   R0,L1                        REPEAT A TOTAL OF 10 TIMES

  • 4 weeks ago

    Using what assembly language? As humans, we do not "write" in "assembly". It is a series of 0's and 1's. We use different languages to write the code and then compile it. Different processors uses different programs. Not enough information to answer the question.

  • 4 weeks ago

    May be or may be not

Still have questions? Get your answers by asking now.