home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / intel8051 / i51misc.asm < prev    next >
Assembly Source File  |  2020-01-01  |  621b  |  46 lines

  1. linput:    mov    dptr,#rcvbuf
  2. linp1:    push    dpl
  3.     push    dph
  4.     call    sys_getc
  5.     pop    dph
  6.     pop    dpl
  7.     movx    @dptr,a
  8.     inc    dptr
  9.     cjne    a,#cr,linp1
  10.     clr    a
  11.     movx    @dptr,a        ; string terminator
  12.     ret
  13. ;
  14. ;=========================================
  15. ;
  16. blkchk:    mov    b,a        ; save check
  17.     anl    a,#192
  18.     swap    a
  19.     rr    a
  20.     rr    a        
  21.     anl    a,#3        ; a = a / 64
  22.     add    a,b        ; add check
  23.     anl    a,#63
  24.     ret
  25. ;
  26. ; compute arithmetic sum
  27. chksum:    mov    r2,#0
  28.     mov    r3,#0ffh
  29.     jnb    parity,cs1
  30.     mov    r3,#07fh
  31. cs1:    movx    a,@dptr
  32.     jz    cs2
  33.     anl    a,r3
  34.     add    a,r2
  35.     mov    r2,a
  36.     inc    dptr
  37.     sjmp    cs1
  38. cs2:    mov    a,r2
  39.     ret
  40. ;
  41. ; calculate kermit checksum, dptr has string start
  42. chkl:    call    chksum
  43.     call    blkchk
  44.     ret
  45. ;
  46.