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

📄 ppp.asm

📁 Application sources:A084.ZIP
💻 ASM
📖 第 1 页 / 共 4 页
字号:
    mov     ecx, MaxRx
to_001:
    cmp     esi, ecx
    jge      to_002
    mov     al, byte [esi + rx_str]
    cmp     al, 3
    jne     to_001a
    mov     al, byte [esi + rx_str + 2]
    cmp     al, 0x80
    je      to_001a
    ; bug fix for chap authenticate reject below
    mov     al, byte [esi + rx_str + 2]
    cmp     al, 0xc2
    jne     to_001a
    and     edx, 0xfd
to_001a:
    push    ecx
    mov     cl, [esi + rx_str]
    dec     cl
    mov     eax, 1
    shl     eax, cl
    and     eax, ebx
    and     eax, 0xffff
    pop     ecx
    cmp     eax, 0
    jnz     to_001b
    xor     edx,edx
to_001b:
    movzx   eax, byte [esi+rx_str+1]
    add     esi, eax
    jmp     to_001
to_002:
    ; if (!(pass&2))...
    test    edx, 2
    jnz     to_exit
    test    edx, 1
    jz      to_002a
    mov     ebx, 0xFFFB
to_002a:
    mov     esi, 8
to_002b:                            ; for loop
    cmp     esi, ecx
    jge      to_003

    push    ecx
    mov     cl, [esi + rx_str]
    dec     cl
    mov     eax, 1
    shl     eax, cl
    and     eax, ebx
    and     eax, 0xffff
    pop     ecx
    cmp     eax, 0
    jnz     to_002c
    movzx   edx, byte [esi+rx_str+1]
to_002d:
    cmp     esi, ecx
    jge      to_002b
    cmp     edx, 0
    jz      to_002b
    mov     al, [esi + rx_str]
    mov     [edi + rx_str], al
    inc     esi
    inc     edi
    dec     edx
    jmp     to_002d
to_002c:
    movzx   eax, byte [esi+rx_str+1]
    add     esi, eax
    jmp     to_002b                 ; end of for loop
to_003:
    mov     eax, edi
    sub     al, 4
    mov     [rx_str+7], al
    xor     edx, edx
    cmp     ebx, 0xfffb
    jne     to_exit
    inc     edx
to_exit:
    ; Return value in EDX
    ret



;***************************************************************************
;    Function
;        disable_port
;
;   Description;
;       Releases this applications use of the com port
;
;***************************************************************************
disable_port:
if DEBUG_PORT2_OUTPUT = TRUE
    mov      eax, 46                 ; free port area
    mov      ebx, 1

    mov      ecx, 0x2f8
    and      ecx, 0xFF0
    mov      edx, ecx
    or       edx, 0x00F
    int      0x40
end if

    mov      eax, 45                 ; free irq 4
    mov      ebx, 1
    mov      ecx, [comirq]
    int      0x40

    mov      eax, 46                 ; free port area
    mov      ebx, 1

    mov      ecx, [comport]
    and      ecx, 0xFF0
    mov      edx, ecx
    or       edx, 0x00F
    int      0x40
    ret



;***************************************************************************
;    Function
;        enable_port
;
;   Description;
;    Takes control of the com port, defining the IRQ table and initialising
;     the uart chip.
;
;***************************************************************************
enable_port:
    pusha
if DEBUG_PORT2_OUTPUT = TRUE
    mov      eax, 46
    mov      ebx, 0
    mov      ecx, 0x2f8
    and      ecx, 0xFF0
    mov      edx, ecx
    or       edx, 0x00F
    int      0x40                     ; reseve port memory to this process

    mov      eax, 45                  ; reserve irq 3
    mov      ebx, 0
    mov      ecx, 3
    int      0x40


    mov      ecx, 0x2f8             ; data format register
    add      ecx, 3
    mov      bl, 0x80               ; enable access to divisor latch
    mov      eax, 43                ; send data to device - com port setup
    int      0x40

    mov      ecx, 0x2f8          ; interrupt enable register
    inc      ecx
    mov      bl, 0                    ; No interruts enabled
    mov      eax, 43                  ; send data to device (modem)
    int      0x40

    mov      ecx, 0x2f8                 ; Divisor latch LSB
    mov      bl, BAUDRATE             ; set baud rate
    mov      eax, 43                  ; send data to device (modem)
    int      0x40

    mov      ecx, 0x2f8             ; Data format register
    add      ecx, 3
    mov      bl, 3                    ; 8 data bits
    mov      eax, 43                  ; send data to device (modem)
    int      0x40

    mov      ecx, 0x2f8        ; Modem control register
    add      ecx, 4                ; ** bl must be 0x0b for modem to dial!
    mov      bl, 0x0b              ; 0x08 -> out2 enabled. No handshaking.
       ; 0xb ->  out2 enabled, RTS/DTR enabled
    mov      eax, 43               ; send data to device (modem)
    int      0x40

;    mov      ecx, 0x2f8        ; interrupt enable register
;    inc      ecx
;    mov      bl, 1                 ; rx data interrupt enabled, othrs not
;    mov      eax, 43               ; send data to device (modem)
;    int      0x40

end if

    mov      eax, 46
    mov      ebx, 0
    mov      ecx, [comport]
    and      ecx, 0xFF0
    mov      edx, ecx
    or       edx, 0x00F
    int      0x40                     ; reseve port memory to this process

    mov      eax, 45                  ; reserve irq 4
    mov      ebx, 0
    mov      ecx, [comirq]
    int      0x40

    mov      eax, 44                  ; setup irq table
    mov      ebx, irqtable
    mov      ecx, [comirq]
    int      0x40

    mov      ecx, [comport]             ; data format register
    add      ecx, 3
    mov      bl, 0x80               ; enable access to divisor latch
    mov      eax, 43                ; send data to device - com port setup
    int      0x40

    mov      ecx, [comport]          ; interrupt enable register
    inc      ecx
    mov      bl, 0                    ; No interruts enabled
    mov      eax, 43                  ; send data to device (modem)
    int      0x40

    mov      ecx, [comport]                 ; Divisor latch LSB
    mov      bl, BAUDRATE             ; set baud rate
    mov      eax, 43                  ; send data to device (modem)
    int      0x40

    mov      ecx, [comport]             ; Data format register
    add      ecx, 3
    mov      bl, 3                    ; 8 data bits
    mov      eax, 43                  ; send data to device (modem)
    int      0x40

    mov      ecx, [comport]        ; Modem control register
    add      ecx, 4                ; ** bl must be 0x0b for modem to dial!
    mov      bl, 0x0b              ; 0x08 -> out2 enabled. No handshaking.
       ; 0xb ->  out2 enabled, RTS/DTR enabled
    mov      eax, 43               ; send data to device (modem)
    int      0x40

    mov      ecx, [comport]        ; interrupt enable register
    inc      ecx
    mov      bl, 1                 ; rx data interrupt enabled, othrs not
    mov      eax, 43               ; send data to device (modem)
    int      0x40

    mov      ecx, [comirq]
    add      ecx, 16
    mov      ebx, 1
    shl      ebx, cl
    add      ebx, 111b
    mov      eax,40                  ; enable irq 4 data
    int      0x40

    popa
    ret



;**************************************************************************
;    Function
;        draw_window
;
;   Description;
;       Normal window definition and text layout for application
;**************************************************************************
draw_window:
    mov      eax, 12                 ; function 12:tell os about windowdraw
    mov      ebx, 1                  ; 1, start of draw
    int      0x40
         ; DRAW WINDOW
    mov      eax, 0                  ; function 0 : define and draw window
    mov      ebx, 100*65536+250      ; [x start] *65536 + [x size]
    mov      ecx, 100*65536+150      ; [y start] *65536 + [y size]
    mov      edx,0x04224466          ; color of work area RRGGBB
    mov      esi,window_label        ; color of grab bar  RRGGBB
    mov      edi,0                   ; color of frames    RRGGBB
    int      0x40
       ; DIAL BUTTON
    mov      eax, 8                  ; function 8 : define and draw button
    mov      ebx, (50)*65536+40      ; [x start] *65536 + [x size]
    mov      ecx, 130*65536+12       ; [y start] *65536 + [y size]
    mov      edx, 2                  ; button id
    mov      esi, 0x5599cc           ; button color RRGGBB
    int      0x40

    mov      ebx, 55*65536+133       ; Draw button text
    mov      ecx, 0x00FFFFFF
    mov      edx, button1_text
    xor      eax, eax
    mov      al,  [button1_text_len]
    mov      esi, eax
    mov      eax, 4
    int      0x40
      ; DISCONNECT BUTTON
    mov      eax, 8                  ; function 8 : define and draw button
    mov      ebx, (150)*65536+65     ; [x start] *65536 + [x size]
    mov      ecx, 130*65536+12       ; [y start] *65536 + [y size]
    mov      edx, 3                  ; button id
    mov      esi, 0x5599cc           ; button color RRGGBB
    int      0x40

    mov      ebx, 155*65536+133      ; Draw button text
    mov      ecx, 0x00FFFFFF
    mov      edx, button3_text
    xor      eax, eax
    mov      al,  [button3_text_len]
    mov      esi, eax
    mov      eax, 4
    int      0x40

    mov      ebx, 5*65536+40         ; draw info text with function 4
    mov      ecx, 0x00FFFFFF
    mov      edx, [prompt]
    xor      eax, eax
    mov      al,  [prompt_len]
    mov      esi, eax
    mov      eax, 4
    int      0x40

    ; Draw IP address
    mov      edx, 10*65536+60
    mov      esi, 0x00FFFFFF
    mov      ebx, 0x00030000
    movzx    ecx, byte [addr1]
    mov      eax, 47
    int      0x40
    mov      edx, 31*65536+60
    mov      esi, 0x00FFFFFF
    mov      ebx, 0x00030000
    movzx    ecx, byte [addr2]
    mov      eax, 47
    int      0x40
    mov      edx, 52*65536+60
    mov      esi, 0x00FFFFFF
    mov      ebx, 0x00030000
    movzx    ecx, byte [addr3]
    mov      eax, 47
    int      0x40
    mov      edx, 73*65536+60
    mov      esi, 0x00FFFFFF
    mov      ebx, 0x00030000
    movzx    ecx, byte [addr4]
    mov      eax, 47
    int      0x40

    ; Status byte
    mov      edx, 100*65536+60
    mov      esi, 0x00FFFFFF
    mov      ebx, 0x00010000
    movzx    ecx, byte [state]
    mov      eax, 47
    int      0x40

    ; bytes sent / received
    mov      eax, 4                  ; function 4 : write text to window
    mov      ebx, 10*65536+80          ; [x start] *65536 + [y start]
    mov      ecx, 0x00ffffff         ; color of text RRGGBB
    mov      edx, txmsg              ; pointer to text beginning
    mov      esi, txmsglen-txmsg    ; text length
    int      0x40

    mov      eax, 4                  ; function 4 : write text to window
    mov      ebx, 10*65536+100          ; [x start] *65536 + [y start]
    mov      ecx, 0x00ffffff         ; color of text RRGGBB
    mov      edx, rxmsg              ; pointer to text beginning
    mov      esi, rxmsglen-rxmsg    ; text length
    int      0x40

    call    draw_window_limited

    mov      eax, 12                 ; end of redraw
    mov      ebx, 2
    int      0x40

    ret



draw_window_limited:
    mov     eax,13
    mov     ebx,80*65536+10*6
    mov     ecx,80*65536+10
    mov     edx,0x03224466
    int     0x40
    mov     eax,13
    mov     ebx,80*65536+10*6
    mov     ecx,100*65536+10
    mov     edx,0x03224466
    int     0x40

    mov     ebx, 0x000A0000
    mov     ecx, [txbytes]
    mov     esi, 0x00ffffff         ; color of text RRGGBB
    mov     eax, 47                  ; function 47 : write number to window
    mov     edx, 80*65536+80          ; [x start] *65536 + [y start]
    int     0x40

    mov     ebx, 0x000A0000
    mov     ecx, [rxbytes]
    mov     esi, 0x00ffffff         ; color of text RRGGBB
    mov     eax, 47                  ; function 47 : write number to window
    mov     edx, 80*65536+100          ; [x start] *65536 + [y start]
    int     0x40
    ret


;****************************************************************************
;    Function
;       settimer
;
;   Description
;       sets the general purpose timer to a given value in eax
;       All times are in 1/100s
;
;
;****************************************************************************
settimer:
    push    eax
    mov     eax, 26
    mov     ebx, 9
    int     0x40        ; get 100th second counter
    pop     ebx
    sub     eax, ebx    ; This could have some funny side effecs if PPP
   ; called within ebx seconds of startup
    mov     [timerValue], eax
    ret


;****************************************************************************
;    Function
;       gettimer
;
;   Description
;       gets the general purpose timer count in eax
;       All times are in 1/100s
;
;
;****************************************************************************
gettimer:
    mov     eax, 26
    mov     ebx, 9
    int     0x40        ; get 100th second counter

    sub     eax, [timerValue]
    ret




;****************************************************************************
;    Function
;       sendwait
;
;   Description
;       Sends a command string to the modem, then waits for a defined rsp
;
;       esi points to string to wait for
;       edi points to string to send
;       edx holds wait time, in ms
;
;       Returns 1 if OK or 0 if timeout occurred
;
;****************************************************************************
sendwait:
    mov     [sendwaitTime], edx

    ; Shrirang 2/5/03
    mov     byte [abortcnt], 0      ; reset the abort counter
    ;--!

    ; Start the timer
    xor     eax, eax
    call    settimer

    ; Check for incoming data

    xor     edx, edx
    xor     eax, eax

sw_001:
    push    eax
    push    edx

    ; Has connection timer expired?
    call    gettimer
    cmp     eax, [sendwaitTime]
    jl      sw_000

    pop     edx
    pop     eax

    xor     eax, eax

    jmp     sw_exit                 ; Exit indicating an error ( timeout )

sw_000:
    ; any data from modem?

    mov     eax,11                     ; This will return 0 most of the time
    int     0x40
    mov     ecx, eax
    pop     edx
    pop     eax


    cmp     ecx, 1                      ; redraw request ?
    je      red1
    cmp     ecx, 3                      ; button in buffer ?
    je      button1
    mov     ebx, [comirq]
    add     ebx, 16
    cmp     ecx,ebx
    jne     sw_002
    jmp     sw_000a

red1:
    pusha
    call    draw_window
    popa
    push    eax
    push    edx

    jmp     sw_000

button1:
    mov     eax, 0
    jmp     sw_exit

sw_000a:
    ; there was data, so get it

    push    edx
    push    eax
    mov     eax,42
    mov     ebx, [comirq]
    int     0x40
    pop     eax
    pop     edx


    ; Shrirang 2/5/03
    ; Now that the expected response is not got we check if we
    ; got the abort part, before we reset the fsm

    cmp     bl, 0x0d     ; AT commands normally start and end with \r\n
    je      checkabort

    cmp     bl, 0x0a
    je      checkabort

    push    eax
    xor     eax, eax
    mov     al, [abortcnt]
    mov     byte [abortres+eax], bl         ; update abort response
    inc     byte [abortcnt]
    pop     eax

    jmp     noabort


checkabort :

    cmp     byte [abortcnt], 2  ; if we got valid abort this cannot happen!
    jbe     noabortflush

    push    eax
    push    esi
    push    edi

⌨️ 快捷键说明

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