3. Stack
* Let FF6 hold LOADLOOP, FF7 hold ENDLOAD, FFS hold ADDLOOP and FF9 hold
ENDLOOP. Assume ap starts from 0*
LOADLOOP:
LODL N5 // load m[sp+N5] into accumulator // 1000 1111 1111 1111
PUSH // decrement sp by 1; load accumulator into m[ep] // 1111 0100 0000 0000
INSP 5 // add 5 to ap// 1111 1100 0000 0101
SWAP // swap ac and ap// 1111 1010 0000 0000
JZER ENDLOAD // if ac = 0, all five numbers are now in stack // 0101 1111 1111 0111
SWAP // swap ac and ap back // 1111 1010 00000000
DESP 5 // subtract 5 from sp.// 1111 1110 0000 0101
JUMP LOADLOOP // repeat loop // 0110 1111 1111 0110
ENDLOAD:
SWAP // swap ac and ap back; ac = N1; a=0 // 1111 1010 0000 0000
DESP 5 // subtract 5 from sp; p=-5 // 1111 1110 0000 0101
LOCO 0 // load 0 into accumulator; ac=0 // 0111 0000 0000 0000
STOD SUM // store content of accumulator into SUM; SUM=0 // 0001 1111 1111 1010
JUMP ADDLOOP // ready to start adding numbers // 0110 1111 1111 1000
ADDLOOP:
POP // load m[ep] into accumulator; increment ap by 1 // 1111 0110 0000 0000 ADDD SUM // adds content of SUM to accumulator // 0010 1111 1111 1010
STOD SUM // store content of accumulator into SUM // 0001 1111 1111 1010
SWAP // swap ac and ap 1111 1010 0000 0000
JZER ENDLOOP // if ac = 0, then all five numbers have been summed // 0101 1111
1111 1001
SWAP // swap ac and ap back 1111 1010 0000 0000
JUMP ADDLOOP // repeat loop // 0110 1111 1111 1000
ENDLOOP:
SWAP // swap ac and ep back, ac=sum, &p=01111 1010 0000 0000
RETN// return; pc = m[0], p=1 // 1111 1000 0000 0000
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
Get Free Quote!
281 Experts Online