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

📄 popc.asm

📁 Application sources:A084.ZIP
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;                                                   ;;
;;    POP CLIENT for MenuetOS                        ;;
;;    - Modified from IRC client                     ;;
;;                                                   ;;
;;    License: GPL / See file COPYING for details    ;;
;;    Copyright 2002 (c) Ville Turjanmaa             ;;
;;                                                   ;;
;;    Compile with FASM for Menuet                   ;;
;;                                                   ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

version equ '0.1'

use32

                org     0x0

                db      'MENUET01'              ; 8 byte id
                dd      0x01                    ; required os
                dd      START                   ; program start
                dd      I_END                   ; program image size
                dd      0x200000                ; required amount of memory
                dd      0xffff0
                dd      0,0

START:                          ; start of execution

    mov  [file_start],0x100000

    mov  eax,58
    mov  ebx,filel
    int  0x40

    cmp  eax,0
    jne  notfound
    add  [file_start],ebx
  notfound:

    mov  edi,I_END
    mov  ecx,60*120
    mov  eax,32
    cld
    rep  stosb

    mov  eax,[rxs]
    imul eax,11
    mov  [pos],eax

    mov  ebp,0
    mov  edx,I_END
    call draw_window            ; at first, draw the window

still:

    mov  eax,5
    mov  ebx,1
    int  0x40

    mov  eax,11                 ; wait here for event
    int  0x40

    cmp  eax,1                  ; redraw
    je   redraw
    cmp  eax,2                  ; key
    je   key
    cmp  eax,3                  ; button
    je   button

    cmp  [I_END+120*60],byte 1
    jne  no_main_update
    mov  [I_END+120*60],byte 0
    mov  edx,I_END
    call draw_server_data
  no_main_update:

    cmp  [server_active],0
    je   noread
    call read_incoming_data
  noread:

    call print_status

    cmp  [status],4
    je   send_request

    jmp  still


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  Save the fetched mails
;;


save_file:

   pusha

   mov  edi,[file_start]

   mov  eax,[file_start]
   sub  eax,0x100000
   mov  [files+8],eax

   mov  eax,58
   mov  ebx,files
   int  0x40

   popa

   ret


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  Send user id/passwd/mailrq
;;


send_request:

    inc  [mcounter]

    cmp  [mcounter],1000
    jbe  no_send

    mov  eax,[ccounter]
    imul  eax,32
    add  eax,getmail
    mov  esi,eax

    inc  [ccounter]

    mov  edx,32

    cmp  [ccounter],1
    jne  no1
    mov  edx,5+2
    add  edx,[l2]
  no1:

    cmp  [ccounter],2
    jne  no2
    mov  edx,5+2
    add  edx,[l3]
  no2:

    mov  eax,53
    mov  ebx,7
    mov  ecx,[socket]
    int  0x40
    mov  [mcounter],0

    cmp  [esi],dword 'quit'
    je   close_fetch


  no_send:

    jmp  still


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  Close connection to server
;;


close_fetch:

    mov  eax,53
    mov  ebx,7
    mov  ecx,[socket]
    mov  edx,14
    mov  esi,quitc
    int  0x40
    mov  [mcounter],0

    mov  eax,5
    mov  ebx,150
    int  0x40

    call read_incoming_data

    mov  eax,53
    mov  ebx,8
    mov  ecx,[socket]
    int  0x40

    mov  eax,5
    mov  ebx,2
    int  0x40

    mov  eax,53
    mov  ebx,8
    mov  ecx,[socket]
    int  0x40

    mov  [server_active],0

    jmp  still


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  User input processing
;;


redraw:                         ; redraw

    call draw_window
    jmp  still


key:

    mov  eax,2
    int  0x40

    jmp  still


button:                         ; button

    mov  eax,17                 ; get id
    int  0x40

    cmp  ah,60
    jne  no_open
    mov  eax,19
    mov  ebx,tp
    mov  ecx,pr
    int  0x40
    jmp  still
  no_open:

    cmp  ah,1                   ; close program
    jne  noclose
    mov  eax,-1
    int  0x40
  noclose:

    cmp  ah,51
    je   read_string
    cmp  ah,52
    je   read_string
    cmp  ah,53
    je   read_string

    call socket_commands

    jmp  still


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  Socket open & close
;;

socket_commands:

    cmp  ah,22       ; open socket
    jnz  tst3

    mov  [server_active],1

    mov  [mcounter],900
    mov  [ccounter],0

    mov  eax,3
    int  0x40

    mov  eax,3
    int  0x40
    mov  ecx,eax
    and  ecx,0xffff

    mov  eax,53
    mov  ebx,5
    mov  edx,110
    mov  esi,dword [ip]
    mov  edi,1
    int  0x40
    mov  [socket], eax

    ret
  tst3:


    cmp  ah,24     ; close socket
    jnz  no_24
    mov  eax,53
    mov  ebx,8
    mov  ecx,[socket]
    int  0x40
    mov  [header_sent],0
    mov  [mail_rp],0
    mov  [server_active],0

    ret
  no_24:

    ret



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  Display connection status
;;

old_status dd 0x0

print_status:

    pusha

    mov  eax,53
    mov  ebx,6
    mov  ecx,[socket]
    int  0x40

    mov  [status],eax

    cmp  eax,[old_status]
    je   nopr

    mov  [old_status],eax

    push eax

    mov  eax,13
    mov  ebx,200*65536+30
    mov  ecx,160*65536+10
    mov  edx,0xffffff
    int  0x40

    pop  ecx

    cmp  [server_active],1
    jne  nopr

    mov  eax,47
    mov  ebx,3*65536
    mov  edx,200*65536+160
    mov  esi,0x000000
    int  0x40

  nopr:

    popa

    ret





;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  Read data from server
;;


read_incoming_data:

    pusha

  read_new_byte:

    call read_incoming_byte
    cmp  ecx,-1
    je   no_data_in_buffer

    mov  eax,[file_start]
    mov  [eax],bl
    inc  [file_start]

    cmp  bl,10
    jne  no_start_command
    mov  [cmd],1
  no_start_command:

    cmp  bl,13
    jne  no_end_command
    mov  eax,[cmd]
    mov  [eax+command-2],byte 0
    call save_file
    call analyze_data
    mov  edi,command
    mov  ecx,250
    mov  eax,0
    cld
    rep  stosb
    mov  [cmd],0
  no_end_command:

    mov  eax,[cmd]
    cmp  eax,250
    jge  still

    mov  [eax+command-2],bl
    inc  [cmd]

    jmp  read_new_byte

  no_data_in_buffer:

    popa

    ret


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  Read user input for ip/user/passwd
;;


read_string:

    shr  eax,8
    sub  eax,51
    mov  ebx,eax
    imul eax,12
    add  eax,181

    mov  [len],ebx
    shl  [len],2
    add  [len],l1

    imul ebx,50
    add  ebx,input1

    mov  [addr],ebx
    mov  [ya],eax

    mov  edi,[addr]
    mov  eax,0
    mov  ecx,30
    cld
    rep  stosb

    call print_input_text

    mov  edi,[addr]

  f11:
    mov  eax,10
    int  0x40
    cmp  eax,2
    jne  read_done
    mov  eax,2
    int  0x40
    shr  eax,8
    cmp  eax,13
    je   read_done
    cmp  eax,8
    jnz  nobsl
    cmp  edi,[addr]
    jz   f11
    sub  edi,1
    mov  [edi],byte 32
    call print_text
    jmp  f11
  nobsl:
    mov  [edi],al

    call print_input_text

    add  edi,1
    mov  esi,[addr]
    add  esi,30
    cmp  esi,edi
    jnz  f11

  read_done:

    push edi

    mov  ecx,40
    mov  eax,32
    cld
    rep  stosb

    call print_input_text

    pop  edi
    sub  edi,[addr]
    mov  eax,[len]
    mov  [eax],edi

    cmp  [len],l1
    jne  noip
    mov  esi,input1
    mov  edi,ip_text+15
    mov  ecx,16
    cld
    rep  movsb
    call ip_set
   noip:

    cmp  [len],l2
    jne  nol2
    mov  esi,input2
    mov  edi,l2_text+15
    mov  ecx,22
    cld
    rep  movsb
    mov  esi,input2
    mov  edi,getmail+5
    mov  ecx,[l2]
    cld
    rep  movsb
    mov  al,13
    stosb

⌨️ 快捷键说明

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