⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 core.asm

📁 Dos6.0
💻 ASM
📖 第 1 页 / 共 3 页
字号:
                push    ax
                mov     ah, cs:first_unit
                add     ah, cs:units
                cmp     al, ah
                pop     ax
                jae     int25_pass

IFDEF DEBUG
                push    ds
                push    cs
                pop     ds
                DBG     '<'
                DBG     'I'
                DBG     'N'
                DBG     'T'
                DBG     '2'
                DBG     '5'
                DBG     '>'
                pop     ds
ENDIF

                mov     ax, 0102H
                stc
                retf

int25_pass:     jmp     dword ptr cs:old_int25_vec

int25_handler   ENDP

int26_handler   PROC    FAR

                cmp     al, cs:first_unit
                jb      int26_pass

                push    ax
                mov     ah, cs:first_unit
                add     ah, cs:units
                cmp     al, ah
                pop     ax
                jae     int26_pass

IFDEF DEBUG
                push    ds
                push    cs
                pop     ds
                DBG     '<'
                DBG     'I'
                DBG     'N'
                DBG     'T'
                DBG     '2'
                DBG     '6'
                DBG     '>'
                pop     ds
ENDIF

                mov     ax, 0102H
                stc
                retf

int26_pass:     jmp     dword ptr cs:old_int26_vec

int26_handler   ENDP

send_sync_proc  PROC    NEAR
                PUBLIC  send_sync_proc

                mov     idle_semaphore, 0   ; Insure idler off during sync
                cmp     port_address, 0
                jne     sync_ok             ; Skip sync if connected already

                xor     bx, bx
                mov     port_num, bl

parallel_loop:  mov     al, port_num
                cmp     al, num_par_ports
                jae     scan_serial

                mov     ax, parallel_ports[bx].PARALLEL_PORT_DEF.pp_address
                mov     port_address, ax
                call    save_par_vec
                call    show_dot
                call    send_sync_pvec
                jc      par_reset

                mov     is_serial, 0
                mov     ax, send_pack_pvec
                mov     send_pack, ax
                mov     ax, recv_pack_pvec
                mov     recv_pack, ax
                jmp     short save_index

par_reset:      call    restore_par_vec
                inc     port_num
                add     bx, TYPE PARALLEL_PORT_DEF
                jmp     parallel_loop

scan_serial:    xor     bx, bx
                mov     port_num, bl

serial_loop:    mov     al, port_num
                cmp     al, num_ser_ports
                jae     scan_fail

                mov     ax, serial_ports[bx].SERIAL_PORT_DEF.sp_address
                mov     port_address, ax
                call    init_port_serial
                call    show_dot
                call    send_sync_serial
                jc      ser_reset

                mov     is_serial, 1
                mov     send_pack, DVR:send_pack_serial
                mov     recv_pack, DVR:recv_pack_serial

save_index:     mov     port_index, bx          ; Save index into port array
                mov     idle_semaphore, MINIMUM_TICKS + 1

sync_ok:        clc
                jmp     short send_sync_ret
                
ser_reset:      call    reset_port_serial
                inc     port_num
                add     bx, TYPE SERIAL_PORT_DEF
                jmp     serial_loop

scan_fail:      mov     port_address, 0
                stc

send_sync_ret:  ret

send_sync_proc  ENDP

reset_drives    PROC    NEAR

                push    ds
                pop     es
                mov     di, DVR:drive_mapping
                mov     si, DVR:default_mapping
                mov     cx, MAX_DEVICES
            rep movsb
                ret

reset_drives    ENDP

reset_printers  PROC    NEAR

                push    ds
                pop     es
                mov     al, UNASSIGNED
                mov     di, DVR:actual_prn_map
                xor     ch, ch
                cmp     printer_loaded, 0
                mov     cl, 3
                je      @F

                mov     cl, num_lpt
            rep stosb
                mov     cl, 3
                sub     cl, num_lpt
                mov     al, DONT_CARE

@@:         rep stosb

                ret

reset_printers  ENDP

; get_remote_info sends an INIT_PACKET to the remote.  The remote should
; respond with an array of BPBs for all devices on the remote system.
;
; Inputs:
;   max_devices         Maximum number of devices driver can support
;   dos_version         The word format of the dos versin number
;   max_secsize         Maximum sector size this DOS version can support
;   first_unit          Device number of the first unit in this driver
;
; Outputs:
;   CF                  Set if successful initialization transaction
;                       Clear if some error occured
;
;   dd_attributes       Attribute word array (one word/device)
;   slave_dos_version   DOS version in WORD format of slave system
;   server_major Server program version number
;   initialized         Set if successful communication
;
;   If a communication error occures, the above variables will not be modified.
;
; All registers are destroyed.
;
gri_proc        PROC    NEAR
                PUBLIC  gri_proc

;--- Send server info request (a zero word) ---
                mov     word ptr packet_buf.common_packet.packet_type, 0
                push    ds
                pop     es
                mov     si, DVR:packet_buf
                mov     cx, 2
                call    send_pack
                jc      gr_fail

                mov     di, DVR:packet_buf
                mov     cx, ((TYPE server_info_r + 1) SHR 1)
                xor     ax, ax
        rep     stosw                       ; Zero unused fields
                mov     packet_buf.server_info_r.sir_os_type, OS_MSDOS
                mov     packet_buf.server_info_r.sir_developer, DEV_SEWELL
                mov     packet_buf.server_info_r.sir_product, PRODUCT_DOSLINK
                mov     packet_buf.server_info_r.sir_version, PRODUCT_VERSION
                mov     packet_buf.server_info_r.sir_device_driver, 1
                mov     packet_buf.server_info_r.sir_want_supported, 0
                mov     packet_buf.server_info_r.sir_checksum, 0
                mov     packet_buf.server_info_r.sir_crc, 1
                mov     packet_buf.server_info_r.sir_max_ser_block, MAX_SERIAL_BLOCK
                mov     si, DVR:client_id
                mov     di, DVR:packet_buf.server_info_r.sir_client_id
                mov     cx, 4
        rep     movsw
                mov     si, DVR:packet_buf
                mov     cx, TYPE server_info_r
                call    send_pack
                jc      gr_fail

                mov     di, DVR:packet_buf
                mov     cx, MAX_PACKET
                call    recv_pack
                jc      gr_fail

                mov     ax, packet_buf.server_info_a.sia_max_ser_block
                mov     max_serial_block, ax
                mov     di, DVR:client_id
                mov     si, DVR:packet_buf.server_info_a.sia_last_client_id
                mov     cx, 4
        repe    cmpsw
                je      check_support

                mov     initialized, 0
                call    reset_drives
                mov     si, DVR:packet_buf.server_info_a.sia_server_id
                mov     di, DVR:last_server_id
                movsw               ; Update last_server_id
                movsw

check_support:  cmp     packet_buf.server_info_a.sia_device_server, 0
                je      gr_fail

                cmp     initialized, 0
                jnz     gr_success

                call    reset_printers
                mov     packet_buf.common_packet.packet_type, INIT_PACKET_REQ
                mov     al, default_units   ; Send default units for max dev.
                mov     packet_buf.init_packet_r.ipr_max_devices, al
                mov     ax, dos_version
                mov     packet_buf.init_packet_r.ipr_dos_version, ax
                mov     WORD PTR packet_buf.init_packet_r.ipr_major_version, (MAJOR_VER OR (MINOR_VER SHL 8))
                mov     al, first_unit
                mov     packet_buf.init_packet_r.ipr_first_unit, al
                mov     si, DVR:actual_prn_map
                mov     di, DVR:packet_buf.init_packet_r.ipr_prn_map
                push    ds
                pop     es
                mov     cx, 3 + MAX_DEVICES
            rep movsb

                mov     cx, TYPE init_packet_r
                mov     si, DVR:packet_buf
                push    ds
                pop     es

                call    send_pack       ; Send init packet
                jc      gr_fail

                push    ds
                pop     es
                mov     di, DVR:packet_buf
                mov     cx, MAX_PACKET  ; es:di, cx -> receive buffer

                call    recv_pack       ; get init response
                jc      gr_fail

                mov     ax, packet_buf.init_packet_a.ipa_dos_version  ; Save version numbers
                mov     slave_dos_version, ax
                mov     ax, WORD PTR packet_buf.init_packet_a.ipa_major_version
                mov     WORD PTR server_major, ax
                mov     al, packet_buf.init_packet_a.ipa_multitasker
                mov     server_multitasker, al

                mov     cx, 3 + MAX_DEVICES
                mov     si, DVR:packet_buf.init_packet_a.ipa_prn_map
                mov     di, DVR:actual_prn_map
                push    ds
                pop     es
            rep movsb

                mov     cl, packet_buf.init_packet_a.ipa_devices
                xor     ch, ch          ; cx = number of devices
                mov     slave_units, cl ; Save slave units
                mov     si, DVR:packet_buf.init_packet_a.ipa_attributes
                mov     di, DVR:dd_attributes
            rep movsw                   ; Copy device driver attributes

                mov     al, 0FFH
                mov     initialized, al ; Set initialized flag
                mov     cx, MAX_DEVICES ; Set media invalid flag for all drives
                mov     di, DVR:invalid ; NOTE: ES and AL set up above
            rep stosb

gr_success:     clc                     ; Return success flag
                ret

gr_fail:        stc                     ; Return fail flag
                ret

gri_proc        ENDP


IFDEF DEBUG
MIN_OFFSET      EQU     3 * 2 * 80
MAX_OFFSET      EQU     20 * 2 * 80
screen_offset   dw      (MIN_OFFSET + MAX_OFFSET) / 2
screen_seg      dw      0B800H

debug_init      PROC    NEAR
                PUBLIC  debug_init

                mov     ah, 15
                int     10H
                cmp     al, 7
                jne     color_seg

                mov     screen_seg, 0B000H
                jmp     short init_done

color_seg:      mov     screen_seg, 0B800H

init_done:      ret

debug_init      ENDP

debug_ret       dw      ?

debug_msg_proc  PROC    NEAR

; AX has been pushed on the stack before calling this routine
; Output the character in AL
;   ALL REGISTERS AND FLAGS PRESERVED

                pop     debug_ret
                pushf
                push    es
                push    di
                mov     di, cs:screen_seg
                mov     es, di
                mov     ah, 70H
                mov     di, cs:screen_offset
                stosw
                cmp     di, MAX_OFFSET
                jb      @F

                mov     di, MIN_OFFSET

@@:             mov     ax, 720H
                mov     es:[di], ax
                mov     cs:screen_offset, di
                pop     di
                pop     es
                popf
                pop     ax
                jmp     debug_ret

debug_msg_proc  ENDP

hex_nibble      PROC    NEAR

                and     al, 0FH
                add     al, '0'
                cmp     al, '9'
                jbe     @F

                add     al, 7

@@:             ret

hex_nibble      ENDP


hex_out_proc    PROC    NEAR

; Output value in AL as hex digits
;   ALL REGISTERS AND FLAGS PRESERVED

                pushf
                push    ax
                mov     ah, al
                shr     al, 1
                shr     al, 1
                shr     al, 1
                shr     al, 1
                call    hex_nibble          ; Prepare original high nibble
                call    debug_msg_proc
                push    ax
                call    hex_nibble          ; Prepare original low nibble
                call    debug_msg_proc
                popf
                ret

hex_out_proc    ENDP
ENDIF

CORE            ENDS

                END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -