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

📄 nntpc.asm

📁 menuet os应用程序源代码,很多汇编写的应用程序
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;   NNTP CLIENT v 0.1
;;
;;   (C) Ville Turjanmaa
;;

version equ '0.1'

use32

               org    0x0

               db     'MENUET01'              ; 8 byte id
               dd     0x01                    ; header version
               dd     START                   ; start of code
               dd     I_END                   ; size of image
               dd     0x80000                ; memory for app
               dd     0x7fff0                 ; esp
               dd     0x0 , 0x0               ; I_Param , I_Icon


connect_state  db  0,0,'Disconnected'
               db  1,3,'Trying..    '
               db  4,4,'Connected   '
               db  5,9,'Closing..   '

prev_state     dd  -1

space          dd  0x0

text_start     dd  0x0

text_current   dd  0x0

status     dd  0x0

server_ip  db  192,168,0,96

socket     dd  0x0

xpos       dd  0x0
ypos       dd  0x0

;;

group      db  'GROUP alt.test',13,10
           db  '                              '

grouplen   dd  16

stat       db  'STAT                          '

statlen    dd  0x0

article    db  'ARTICLE',13,10
articlelen:

;;

quit       db  'QUIT',13,10
quitlen:

xwait      dd  0x0
ywait      dd  0x0

article_n  dd  0x0
article_l  dd  0x0

article_start dd 0x0
article_last dd 0x0
article_all  dd 0x0

article_fetch dd 0x0

xpost      dd  0x0

edisave    dd  0x0


connection_status:

    pusha

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

    cmp  eax,[prev_state]
    je   no_cos

    mov  [prev_state],eax

    mov  eax,13
    mov  ebx,435*65536+12*6
    mov  ecx,42*65536+10
    mov  edx,0xffffff
    int  0x40

    mov  ecx,-14
    mov  eax,[prev_state]

  next_test:

    add  ecx,14

    cmp  ecx,14*4
    je   no_cos

    cmp  al,[connect_state+ecx+0]
    jb   next_test
    cmp  al,[connect_state+ecx+1]
    jg   next_test

    mov  edx,ecx
    add  edx,2
    add  edx,connect_state

    mov  eax,4
    mov  ebx,435*65536+42
    mov  ecx,0x000000
    mov  esi,12
    int  0x40

  no_cos:

    popa

    ret



text_input:

    pusha
    mov  ecx,25
    mov  eax,32
    cld
    rep  stosb
    popa

    mov  [edisave],edi

  ti0:

    mov  [edi],byte ' '
    call draw_entries

    mov  eax,10
    int  0x40

    cmp  eax,2
    jne  no_more_text

    mov  eax,2
    int  0x40

    cmp   ah,8
    jne   no_bg
    cmp   edi,[edisave]
    je    ti0
    dec   edi
    jmp   ti0
   no_bg:

    cmp  ah,13
    je   no_more_text

    mov  [edi],ah
    inc  edi

    call draw_entries

    jmp  ti0

  no_more_text:

    mov  [xpost],edi

    ret


convert_text_to_ip:

    pusha

    mov   edi,server_ip
    mov   esi,text+10
    mov   eax,0
    mov   edx,[xpost]
  newsip:
    cmp   [esi],byte '.'
    je    sipn
    cmp   esi,edx
    jge   sipn
    movzx ebx,byte [esi]
    inc   esi
    imul  eax,10
    sub   ebx,48
    add   eax,ebx
    jmp   newsip
  sipn:
    mov   [edi],al
    xor   eax,eax
    inc   esi
    cmp   esi,text+50
    jg    sipnn
    inc   edi
    cmp   edi,server_ip+3
    jbe   newsip
  sipnn:

    popa

    ret


send_group:

    mov  eax,53
    mov  ebx,7
    mov  ecx,[socket]
    mov  edx,[grouplen]
    mov  esi,group
    int  0x40
    mov  [status],3
    call clear_text
    call save_coordinates

    ret


convert_number_to_text:

    pusha

    mov  eax,[esi]
    mov  ecx,0
  newch:
    inc  ecx
    xor  edx,edx
    mov  ebx,10
    div  ebx
    cmp  eax,0
    jne  newch

    add  edi,ecx
    dec  edi
    mov  [article_l],ecx

    mov  eax,[esi]
  newdiv:
    xor  edx,edx
    mov  ebx,10
    div  ebx
    add  edx,48
    mov  [edi],dl
    dec  edi
    loop newdiv

    popa

    ret


convert_text_to_number:

    pusha

    mov   edx,0
  newdigit:
    movzx eax,byte [esi]
    cmp   eax,'0'
    jb    cend
    cmp   eax,'9'
    jg    cend
    imul  edx,10
    add   edx,eax
    sub   edx,48
    inc   esi
    jmp   newdigit
  cend:
    mov   [edi],edx
    popa

    ret


clear_text:

    mov  [text_start],0
    mov  [xpos],0
    mov  [ypos],0
    mov  [xwait],0
    mov  [ywait],0
    mov  edi,nntp_text
    mov  ecx,0x50000
    mov  eax,32
    cld
    rep  stosb
    ret


state_machine_write:


    cmp  [status],2
    jne  no_22
    call send_group
    ret
  no_22:

    cmp  [status],4
    jne  no_4
    mov  eax,53
    mov  ebx,7
    mov  ecx,[socket]
    mov  edx,[statlen] ; -stat
    mov  esi,stat
    int  0x40
    mov  [status],5
    call save_coordinates
    ret
  no_4:

    cmp  [status],6
    jne  no_6
    mov  eax,53
    mov  ebx,7
    mov  ecx,[socket]
    mov  edx,articlelen-article
    mov  esi,article
    int  0x40
    mov  [status],7
    call save_coordinates
    ret
  no_6:


    ret

save_coordinates:

    mov  eax,[xpos]
    mov  ebx,[ypos]
    mov  [xwait],eax
    mov  [ywait],ebx

    ret


state_machine_read:

    cmp  [status],1
    jne  no_1
    mov  eax,'200 '
    call wait_for_string
    ret
  no_1:

    cmp  [status],3   ;; responce to group
    jne  no_3
    mov  eax,'211 '
    call wait_for_string
    ret
  no_3:

    cmp  [status],5   ;; responce to stat
    jne  no_5
    mov  eax,'223 '
    call wait_for_string
    ret
  no_5:

    ;; after 'article' request - no wait

    cmp  [status],9
    jne  no_9
    mov  eax,'222 '
    call wait_for_string
    ret
  no_9:



    ret



wait_for_string:

    mov  ecx,[ywait]
    imul ecx,80
    add  ecx,[xwait]

    mov  ecx,[nntp_text+ecx]

    cmp  eax,ecx
    jne  no_match

    cmp  [status],3
    jne  no_stat_ret

    mov  esi,[ywait]
    imul esi,80
    add  esi,[xwait]

  new32s:
    inc  esi
    movzx eax,byte [esi+nntp_text]
    cmp  eax,47
    jge  new32s
  new32s2:
    inc  esi
    movzx eax,byte [esi+nntp_text]
    cmp  eax,47
    jge  new32s2
    inc  esi
    add  esi,nntp_text
;    mov  [esi-1],byte '.'

    mov  edi,article_n
    call convert_text_to_number
    mov  eax,[article_n]
    mov  [article_start],eax

  new32s3:
    inc  esi
    movzx eax,byte [esi]
    cmp  eax,47
    jge  new32s3
    inc  esi

    mov  edi,article_last
    call convert_text_to_number

    mov  eax,[text_current]
    add  [article_n],eax

    mov  esi,article_n
    mov  edi,nntp_text+71
    call convert_number_to_text

    mov  esi,article_n
    mov  edi,stat+5
    call convert_number_to_text

    mov  eax,[article_l]
    mov  [stat+5+eax],byte 13
    mov  [stat+6+eax],byte 10
    add  eax,5+2
    mov  [statlen],eax

    pusha
    mov  edi,text+10+66*2
    mov  ecx,25
    mov  eax,32
    cld
    rep  stosb
    mov  esi,text_current
    mov  edi,text+10+66*2
    call convert_number_to_text
    mov  eax,32
    mov  ecx,20
    mov  edi,text+10+66*3

⌨️ 快捷键说明

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