Mercurial > hg > Members > kono > nitros9-code
view lib/alib/div16x16.a @ 2772:0a3f4d8ea6d5
Found ENDC in wrong location in dwread.asm and dwwrite.asm. Corrected.
Moved the native 6309 code in dwread.asm and dwwrite.asm into the H6309 labeled area and changed IFEQ H6309 to IFNE H6309. Also moved the 57600bps 6809 code to the default location. This change had been done in the old dwread.asm and dwwrite.asm files to make it easier to follow. Though these two files were overwritten from the HDBDOS project dwread.asm and dwwrite.asm files. So this conversion needed to be done again so it made the source easier to follow.
author | drencor-xeen |
---|---|
date | Wed, 23 Jan 2013 12:36:55 -0600 |
parents | 7d70b7e1cb21 |
children | aaba193af04f |
line wrap: on
line source
********************************************* * 16 x 16 bit integer divide * OTHER MODULES NEEDED: none * ENTRY: D = divisor * X = dividend * EXIT: X = quotient * D = remainder nam 16x16 bit Divide ttl Assembler Library Module psect DIV16,0,0,0,0,0 vsect negcount rmb 1 endsect * Signed Divide SDIV16: clr negcount,u PSHS D,X tst ,s bpl testquo ldd ,s comb coma addd #$0001 std ,s inc negcount,u testquo tst 2,s bpl ok ldd 2,s comb coma addd #$0001 std 2,s inc negcount,u ok puls d,x bsr DIV16 dec negcount,u bne goforit pshs d,x ldd ,s coma comb addd #$0001 std ,s ldd 2,s coma comb addd #$0001 std 2,s puls d,x goforit rts * Unsigned Divide DIV16: PSHS D,X save divisor & dividend LDA #16 bit counter PSHS A CLRA initialize remainder CLRB div1 ASL 4,S shift dividend & quotient ROL 3,S ROLB shift dividend into B ROLA CMPD 1,S trial subtraction reqd? BLO div2 SUBD 1,S yes, do subtraction INC 4,S increment quotient div2 DEC ,S count down another bit BNE div1 LDX 3,S get quotient LEAS 5,S clean stack RTS endsect