Question: Task 2 - Vector addition 2 points - Write a macro program that adds two two - component vectors. The two vectors should first be
Task Vector addition
points Write a macro program that adds two twocomponent vectors. The two vectors should first be stored as
pairs of numbers on the stack, the addition function clears these and stores the result on the stack.
Start with the following approach for the two vectors and and the sum :
main
BIPUSH
BIPUSH
BIPUSH
BIPUSH
endmain
points Now extend the instruction set microcode to include vector addition. The name of the function should
be IVECADD and it should not have any parameters; the vectors are passed via the stack.
The value Value corresponds to the line in the microprogram in which the first line of the implementation is
located. Precede the first line with a hexadecimal value in brackets that corresponds to the previous Value The
function will be in this line after compilation. This value should be unique in the microprogram, otherwise you will
receive an error message.
By calling the stack, the last four words on the stack from bottom to top: Vectorx Vectory Vectorx Vectory
should be replaced by the two words of the solution. After a call, the original vectors are gone! THIS IS A MIC CODE
THIS is not a macroassembly code
This is a microprogramm code so what you need to do is to create such a microassembler that is named IVECADD which has language like this:
Main: PCPC; fetch; gotoMBR
xNOP:; goto Main
xBIPUSH: SPMARSP;
PCPC; fetch
MDRTOSMBR; wr; goto Main;
xISUB: MARSPSP; rd
HTOS
MDRTOSMDRH; wr; goto Main
xIAND: MARSPSP; rd
HTOS
MDRTOSMDR AND H; wr; goto Main
xIOR:MARSPSP; rd
HTOS
MDRTOSMDR OR H; wr; goto Main
xDUP: MAR SP SP
MDRTOS;wr;goto Main
xPOP: MARSPSP; rd;
pop: wait
TOSMDR;goto Main
xSWAP: MARSP; rd;
MARSP
HMDR;wr
MDRTOS
MARSP; wr
TOSH; goto Main
xDIADD: MARSPSP; rd
HTOS
MDRTOSMDRH; wr; goto Main
xFILOAD:HLV;
MARMBRUH;rd;
iload: MARSPSP;
PCPC; fetch; wr;
TOSMDR; goto Main
xISTORE: HLV
MARMBRUH
istore: MDRTOS;wr;
SPMARSP;rd
PCPC;fetch
TOSMDR; goto Main
xAWIDE: PCPC; fetch; gotoMBR or x
xBLDCW: PCPC; fetch;
HMBRU
HMBRU OR H
MARHCPP; rd; goto iload
xFIINC: HLV
MARMBRUH; rd
PCPC; fetch
HMDR
PCPC; fetch
MDRMBRH; wr; goto Main
xAGOTO:OPCPC
goto: PCPC; fetch;
HMBR
HMBRU OR H
PCOPCH; fetch
goto Main
xIFLT: MARSPSP; rd;
OPCTOS
TOSMDR
NOPC; ifN goto T; else goto F
xIFEQ:MARSPSP; rd;
OPCTOS
TOSMDR
ZOPC; ifZ goto T; else goto F
xIFICMPEQ: MARSPSP; rd
MARSPSP
HMDR;rd
OPCTOS
TOSMDR
ZOPCH; ifZ goto T; else goto F
F:PCPC
PCPC; fetch;
goto Main
xFT:OPCPC;fetch; goto goto
xBINVOKEVIRTUAL:PCPC; fetch
HMBRU
H MBRU OR H
MARCPP H; rd
OPC PC
PCMDR; fetch
PCPC; fetch
H MBRU
H MBRU OR H
PCPC; fetch
TOSSPH
TOSMARTOS
PCPC; fetch
H MBRU
H MBRU OR H
MDR SP H ; wr
MARSPMDR
MDR OPC; wr
MAR SP SP
MDR LV; wr
PCPC; fetch
LVTOS; goto Main
xCCIRETURN:MARSPLV; rd
ireturn: wait
LVMARMDR; rd
MARLV
PCMDR;rd;fetch
MARSP
LVMDR
MDRTOS; wr; goto Main
addtional information:
you need to test run it in following website to ensure it is working: https:vsude.github.iomictoolbox
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
