Please tell me the assembly language program.If possible, I would like you to make a program.

Asked 1 years ago, Updated 1 years ago, 332 views

Using the code below as reference, what program calculates A×B×C×D+E×F×G with 7 numbers as A:1, B:2, C:10, D:8, E:10, F:5, G:6?
The result is 460.

Program to calculate AxB+CxD

SAMPLE START
    LD GR0, A
    LD GR1,B
    CALL MUL
    STGR2, ANS
    LD GR0,C
    LD GR1,D
    CALL MUL
    ADDA GR2, ANS
    STGR2, ANS
    RET
MUL START
    PUSH 0, GR3
    LD GR2, CONST0
    LD GR3, CONST0
LOOP CPA GR3, GR1
    JZELABEL1
    ADDA GR2, GR0
    ADDA GR3, CONST1
    JUMP LOOP
LABEL 1 POP GR3
    RET
A DC 4
BDC3
CDC2
DDC5
ANS DC 0
CONST0 DC0
CONST1 DC1
    END

A×B and C×D have been made, but I can't put those two on again.
Similarly, E×F and G cannot be multiplied again.
Please let me know so that I can add A×B×C×D and E×F×G after that.
 

assembly-language

2022-09-30 22:04

2 Answers

It's a little hesitant to answer the program source of the results in terms of the content of the questions, so if you just show your thinking, you'll get to this step.
Results·Answer·Multiplication routine should be read from the program source provided in the question.

    Define additional areas for
  • E, F, G and set A to F to the specified values
  • The main part of the program should be:
    • A and B are loaded into the register to invoke the multiplication routine
    • Storing multiplication results in answers
    • C and D are loaded into the register to invoke the multiplication routine
    • Load the multiplication results and answers to the register and call the multiplication routine
    • Storing multiplication results in answers
    • E and F are loaded into the register to invoke the multiplication routine
    • Call multiplication routines by loading multiplication results and G into the register
    • Add answers to multiplication results
    • Storing the result of the addition in the answer
    • Exit
  • A and B are loaded into the register to invoke the multiplication routine
  • Storing multiplication results in answers
  • C and D are loaded into the register to invoke the multiplication routine
  • Load the multiplication results and answers to the register and call the multiplication routine
  • Storing multiplication results in answers
  • E and F are loaded into the register to invoke the multiplication routine
  • Call multiplication routines by loading multiplication results and G into the register
  • Add answers to multiplication results
  • Storing the result of the addition in the answer
  • Exit

The number of editions seems a little old, but there is an emulator below, so you can easily check it.
CASLII emulator


2022-09-30 22:04

I think it would be better to reverse assembly and compare it with the source code.


2022-09-30 22:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.