Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

Even 3 more (Users)

posted by DOS386, 13.04.2009, 10:07

- COPY command silently overwrites existing files (not if they are Read Only at least, though), FreeDOS is better here

- The source contains a HEX16 conversion routine that is bloated and inefficient (but "correct" at least), see other thread

- The source contains some fancy "db 0fh,31h" code not accessed from anywhere, forgotten debug code? Also no preceding "db 0fh,a2h" code seems to exist :confused: Actually the HEX16 code seems to be accessed from this code only so it is apparently useless anyway ,,, :clap:

; From DRDOS\BDEVIO.A86 2009-03-28

mul64:                              ; 64-bit multiplication
;--------
; On Entry:
;      64-bit factors on stack
;      space for 128-bit product reserved on stack
;      SP-32
; On Exit:
;      64-bit product on stack
;      SP-32
;      Carry flag set if result does not fit in quad word
; Modified registers:
;      AX,BX,CX,DX
        push      es                  ; save ES
        push      bp                  ; save BP
        push      si                  ; save SI
        push      di                  ; save DI
        push      ss
        pop      es
        mov      bp,sp                  ; base address of temporary variables
        add      bp,10
        mov      di,bp                  ; clear result
        xor      ax,ax
        mov      cx,4
        cld
        rep      stosw
        xor      si,si                  ; start with lowest words of factors
mul64_10:
        xor      di,di
mul64_20:
        mov      bx,si                  ; compute offset in result
        add      bx,di
        add      bx,4
        mov      cx,16                  ; number of carry additions left
        sub      cx,bx
        shr      cx,1                  ; / 2 = number of word additions
        mov      ax,16[bp+si]            ; multiply two words
        mul      word ptr 24[bp+di]
        xchg      bx,di
        add      -4[bp+di],ax            ; and add the product to the result
        adc      -2[bp+di],dx
        jcxz      mul64_40            ; skip if highest words
mul64_30:
        jnc      mul64_40            ; no carry, so no further adds needed
        adc      word ptr [bp+di],0      ; otherwise add zero
        inc      di
        inc      di
        loop      mul64_30            ; until no carry left over
mul64_40:
        xchg      bx,di
        inc      di                  ; next word in first factor
        inc      di
        cmp      di,6                  ; already highest word?
        jbe      mul64_20            ; next multiplication
        inc      si                  ; next word in second factor
        inc      si
        cmp      si,6                  ; already highest word?
        jbe      mul64_10            ; next multiplication
        mov      cx,4                  ; check if results fits in 64 bits
        xor      si,si
mul64_45:
        cmp      word ptr 8[bp+si],0  ; zero?
        jnz      mul64_50             ; if not, then skip and set carry
        inc      si                   ; next word to compare
        inc      si
        loop      mul64_45          ; until highest dword has been checked
        jmps      mul64_60          ; 64-bit result
mul64_50:
        stc
mul64_60:
        pop      di                  ; restore DI again
        pop      si                  ; restore SI
        pop      bp                  ; restore BP
        pop      es                  ; restore ES
        ret

mul32:                              ; 32-bit multiplication
;--------
; On Entry:
;      32-bit factors on stack
;      space for 64-bit product reserved on stack
;      SP-16
; On Exit:
;      64-bit product on stack
;      SP-16
;      Carry flag set if result does not fit in double word
; Modified registers:
;      AX,DX
        push      bp                ; save BP
        mov      bp,sp              ; base address of temporary variables
        add      bp,4
        mov      ax,10[bp]          ; multiply high word of factors
        mul      word ptr 14[bp]
        mov      4[bp],ax           ; store result
        mov      6[bp],dx
        mov      ax,10[bp]          ; multiply high word of first factor with low word of second
        mul      word ptr 12[bp]
        mov      2[bp],ax           ; add result to previous
        add      4[bp],dx
        adc      word ptr 6[bp],0
        mov      ax,8[bp]           ; multiply low word of first factor with high word of second
        mul      word ptr 14[bp]
        add      2[bp],ax           ; add result to previous
        adc      4[bp],dx
        adc      word ptr 6[bp],0
        mov      ax,8[bp]           ; multiply low word of first factor with low word of second
        mul      word ptr 12[bp]
        mov      [bp],ax            ; add result
        add      2[bp],dx
        adc      word ptr 4[bp],0
        adc      word ptr 6[bp],0
        cmp      word ptr 4[bp],0   ; 64-bit result?
        jnz      mul32_1            ; yes
        cmp      word ptr 6[bp],0
        jz      mul32_2             ; no
mul32_1:
        stc                         ; yes, set carry flag to indicate this
mul32_2:
        pop      bp                 ; restore BP again
        ret

        public      read_tsc
read_tsc:
        push     dx
        push     ax
        db       0fh,31h            ; RDTSC
        db       66h                ; MOV lasttsc+4,EDX
        mov      lasttsc+4,dx
        db       66h                ; MOV lasttsc,EAX
        mov      lasttsc,ax
        pop      ax
        pop      dx
        ret

        public      diff_tsc
diff_tsc:
        push     dx
        push     cx
        push     bx
        push     ax
        db       0fh,31h            ; RDTSC
        db       66h                ; MOV ECX,lasttsc+4
        mov      cx,lasttsc+4
        db       66h                ; MOV EBX,lasttsc
        mov      bx,lasttsc
        db       66h                ; SUB EAX,EBX
        sub      ax,bx
        db       66h                ; SBB EDX,ECX
        sbb      dx,cx
        cmp      tscsel,0
        je       diff_tsc10
        db       66h
        push     dx
        db       66h
        push     ax
        mov      dx,tscsel
        call     output_hex
        db       66h
        pop      ax
        db       66h
        pop      dx
        db       66h
        xor      bx,bx
        mov      bx,tscsel
        dec      bx
        shl      bx,1
        shl      bx,1
        shl      bx,1
        db       66h
        add      tsc1[bx],ax
        db       66h
        adc      tsc1+4[bx],dx
        db       66h
        mov      ax,tsc1[bx]
        db       66h
        mov      dx,tsc1+4[bx]
diff_tsc10:
        db       66h                  ; PUSH EAX
        push     ax
        db       66h                  ; PUSH EDX
        push     dx
        pop      ax
        pop      dx
        call     output_hex
        xchg     ax,dx
        call     output_hex
        pop      ax
        pop      dx
        call     output_hex
        xchg     ax,dx
        call     output_hex
        pop      ax
        pop      bx
        pop      cx
        pop      dx
        ret

        public      output_msg
output_msg:
;----------------
; On Entry:
;      si = offset CGROUP:message_msg
; On Exit:
;      None
        push     ax
        push     bx
        lodsb                       ; get 1st character (never NULL)
output_msg10:
        mov      ah,0Eh
        mov      bx,7
        int      10h                ; TTY write of character
        lodsb                       ; fetch another character
        test     al,al              ; end of string ?
        jnz      output_msg10
        pop      bx
        pop      ax
        ret

        public      output_hex
output_hex:
;----------------
; On Entry:
;      dx = 2 byte hex value
; On Exit:
;      None
; Used Regs:
;      ax,bx,cx,dx,si
        push     ax
        push     bx
        push     cx
        push     si
        push     ds
        mov      cx,4
        mov      ah,0eh
        mov      bx,7
output_hex10:
        mov      al,dh
        push     cx
        mov      cl,4
        shr      al,cl
        pop      cx
        and      al,0fh
        cmp      al,09h             ; greater 0-9?
        jg       output_hex20
        add      al,30h
        jmp      output_hex30
output_hex20:
        add      al,37h
output_hex30:
        int      10h
        push     cx
        mov      cl,4
        shl      dx,cl
        pop      cx
        loop     output_hex10
        push     cs
        pop      ds
        lea      si,ds:output_hex40
        call     output_msg
        pop      ds
        pop      si
        pop      cx
        pop      bx
        pop      ax
        ret

output_hex40 db 20h,0               ; end of string

        end

---
This is a LOGITECH mouse driver, but some software expect here
the following string:*** This is Copyright 1983 Microsoft ***

 

Complete thread:

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