Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

New version DRDOS 7.01.7 & 7.01.8 (Announce)

posted by boeckmann, Aachen, Germany, 12.12.2023, 21:15

> > I made some changes to the latest EDR-DOS sources maintained by ecm: > > > > - fixed bug in DRDOS.SYS div32 function, leading to division errors on > > partitions with more than 66535 FAT sectors. There is also a div32 > function > > in DRBIO.SYS present, but it did not contain the bug. > > https://github.com/SvarDOS/edrdos/commit/167fe71ec058f80b7da47f11f2a34fc66938ad57 > > div16: > mov       ax,12[bp] > mov  dx,14[bp] > > Surely you can xor dx, dx here if you already checked that > word [bp + 14] is zero? > > More to the point if the divisor high word is zero, a two-step division of > two 32/16=16 divisions can be done on a 32-bit dividend (with 32-bit > quotient) which would be faster than the full 32-bit division (that fully > supports 32-bit divisors in addition to dividends/quotients). > > The division functions in DRBIO both do not offer the fast path for smaller > numbers: > > https://github.com/SvarDOS/edrdos/blob/f6584d40d6dda553e63f7682ad672536f53ae6ff/drbio/disk.asm#L3286 > > https://github.com/SvarDOS/edrdos/blob/f6584d40d6d...e63f7682ad672536f53ae6ff/drbio/bdosldr.a86#L772 Yes, by re-arranging a little bit, the unconditional jump can also be eliminated, like so: div32:                                  ; 32-bit division ;-------- ; On Entry: ;       32-bit dividend & divisor on stack ;       space for 32-bit quotient & remainder reserved on stack ;       SP-16 ; On Exit: ;       32-bit quotient & remainder on stack ;       SP-16 ; Modified registers: ;       AX,CX,DX,BP         mov     bp,sp                   ; base address of temporary variables         add     bp,2         cmp     word ptr 10[bp],0       ; if divisor high => 32bit div          jne    div32_full         cmp     word ptr 14[bp],0       ; if dividend high => 32bit div          jne    div32_full div16:  mov     ax,12[bp]               ; AX=low 16 bits of dividend         xor     dx,dx         div     word ptr 8[bp]         xor     cx,cx         mov     [bp],dx         mov     2[bp],cx                ; clear high part of remainder         mov     4[bp],ax         mov     6[bp],cx                ; and quotient result         ret div32_full:         ... I first thought that the xor cx,cx can be eliminated too, by clearing the result after the xor dx,dx. But the xor cx,cx leaves the flags in a defined state, which the div does not. So I think it is safer to leave this xor cx,cx in.

 

Complete thread:

Back to the forum
Board view  Mix view
22825 Postings in 2129 Threads, 402 registered users (0 online)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum