; LMC Sample Program -IAN! idallen@ncf.ca ; ; Some nonsense C++ code, translated to LMC assembly language. ; ;Label Mnem. Operand Comments............. ;----- ----- ------- --------------------- ; cin >> x; IN ; read and store first number STO X ; cin >> y; IN ; read and store second number STO Y ; if ( y <= x ) { LDA X ; if second is <= first SUB Y SKP JMP ENDIF ; cout << ++x + y; LDA X ; pre-increment of X ADD ONE STO X LDA X ; addition of X and Y and output ADD Y OUT ; } ; cout << y-- + x + 3; ENDIF LDA Y ; addition of Y, X, and 3 and output ADD X ADD THREE OUT LDA Y ; post-decrement of Y SUB ONE STO Y HLT ; constants: ONE DAT 001 THREE DAT 003 ; variables: X DAT ? ; int x; Y DAT ? ; int y;