Sha256: 230eb919470f0302a271da86082a2b0bb4bbb1e2330c806ed46258917cba1c25
Contents?: true
Size: 1.15 KB
Versions: 10
Compression:
Stored size: 1.15 KB
Contents
Code is called as a subroutine (i.e. JSR Arithmetic). Specific OS/hardware routines for user input and printing are left unimplemented. 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 The 6502 has no opcodes for multiplication, division, or modulus; the routines for multiplication, division, and modulus given above can be heavily optimized at the expense of some clarity.
Version data entries
10 entries across 7 versions & 1 rubygems