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.
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.
E
, F
, G
and set A
to F
to the specified valuesA
and B
are loaded into the register to invoke the multiplication routineC
and D
are loaded into the register to invoke the multiplication routineE
and F
are loaded into the register to invoke the multiplication routineG
into the registerA
and B
are loaded into the register to invoke the multiplication routineC
and D
are loaded into the register to invoke the multiplication routineE
and F
are loaded into the register to invoke the multiplication routineG
into the registerThe number of editions seems a little old, but there is an emulator below, so you can easily check it.
CASLII emulator
I think it would be better to reverse assembly and compare it with the source code.
© 2024 OneMinuteCode. All rights reserved.