49 lines
856 B
Text
49 lines
856 B
Text
|
|
Arithmetic: PHA ;push accumulator and X register onto stack
|
||
|
|
TXA
|
||
|
|
PHA
|
||
|
|
JSR GetUserInput ;routine not implemented
|
||
|
|
;two integers now in memory locations A and B
|
||
|
|
;addition
|
||
|
|
LDA A
|
||
|
|
CLC
|
||
|
|
ADC B
|
||
|
|
JSR DisplayAddition ;routine not implemented
|
||
|
|
|
||
|
|
;subtraction
|
||
|
|
LDA A
|
||
|
|
SEC
|
||
|
|
SBC B
|
||
|
|
JSR DisplaySubtraction ;routine not implemented
|
||
|
|
|
||
|
|
;multiplication - overflow not handled
|
||
|
|
LDA A
|
||
|
|
LDX B
|
||
|
|
Multiply: CLC
|
||
|
|
ADC A
|
||
|
|
DEX
|
||
|
|
BNE Multiply
|
||
|
|
JSR DisplayMultiply ;routine not implemented
|
||
|
|
|
||
|
|
;division - rounds up
|
||
|
|
LDA A
|
||
|
|
LDX #0
|
||
|
|
SEC
|
||
|
|
Divide: INX
|
||
|
|
SBC B
|
||
|
|
BCS Divide
|
||
|
|
TXA ;get result into accumulator
|
||
|
|
JSR DisplayDivide ;routine not implemented
|
||
|
|
|
||
|
|
;modulus
|
||
|
|
LDA A
|
||
|
|
SEC
|
||
|
|
Modulus: SBC B
|
||
|
|
BCS Modulus
|
||
|
|
ADC B
|
||
|
|
JSR DisplayModulus ;routine not implemented
|
||
|
|
|
||
|
|
PLA ;restore accumulator and X register from stack
|
||
|
|
TAX
|
||
|
|
PLA
|
||
|
|
RTS ;return from subroutine
|