×   Main Menu ALL The 8BS News Manuals (New menu) Links Worth a Look Tools Disc and Basic Webring Site Map 8BS Guestbook Old Guest Book Me The Barnsley Rovers   
8-Bit Software

The BBC and Master Computer Public Domain Library

Integer MOD routine

Submitted by Steve Fewell

Routine: iMOD
Name: Integer MOD routine
Starting Address: &9FF5
Entry criteria: Either IWA or FWA contain the dividend. A contains the variable type (Floating-Point/Integer). The Basic Text Pointer 2 points to an expression (the divisor) [e.g. " A%"]
Exit: The IWA.= The Remainder of IWA / Divisor-expression

Description:
Call the Integer Division routine to evaluate the Divisor-expression and perform the actual division.

Push the sign-bit (&38) of the result to the 6502 stack, load X with &3D (to specify where the result is located, this is done by 9FB2), and call the end of the Integer multiplication routine to put the Result into the IWA, convert it to the correct sign, and to check the next operator to see if any further multiplication/division processing is required.

 

Disassembly for the Integer MOD routine

9FF5   032 249 128 20 F9 80 JSR &80F9    Integer Division
9FF8 8 165 056 A5 38 LDA &38
9FFA   008 08 PHP
9FFB   128 181 80 B5 BRA -75 --> &9FB2    Get Result from Zero Page & check next operator in expression

 


 Back to 8BS
Or