home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 82 / asm / source / ash / binlnk82.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-01  |  5.2 KB  |  243 lines

  1. ;
  2. ;BinLink v1.0 for the TI82 (ASH)
  3. ; by
  4. ; Sami Khawam (sKhawam@bigfoot.com).
  5. ;
  6. ;
  7. ;This is a small program I wrote when I was developping the IR Link
  8. ;in order to debug and test it. This program shows the data coming
  9. ;from the link port in binary mode, and it also let you send bytes
  10. ;also in binary mode.
  11. ;
  12. ;There are only 3 keys used: 1, 0 and Exit.
  13. ;
  14. ;In order to distinguish between what is received and what is
  15. ;sent, the program show the the received data in white-on-black.
  16. ;
  17. ;--
  18. ; Sami Khawam (sKhawam@bigfoot.com)
  19. ;
  20. ; http://unet.univie.ac.at/~a9501901
  21.  
  22.  
  23. #INCLUDE "TI82.H"
  24. #INCLUDE "KEYS.INC"
  25.  
  26. PORT = 000H
  27.  
  28. .ORG START_ADDR
  29. .db "BinLink by Sami Khawam",0
  30.  
  31.  
  32.         ROM_CALL(CLEARLCD)
  33.         ld      de, $0000
  34.         ld      (CURSOR_ROW), de
  35. Start:
  36.         ld      b, 8
  37.  
  38. ProgLoop:
  39.  
  40.         in      a, (PORT)
  41.         and     3
  42.         cp      3
  43.         jr      z, CheckKey
  44.  
  45.         push    bc
  46.         call    GetByte
  47.         ld      c, a
  48.         call    DispCBin
  49.         pop     bc
  50.  
  51.  
  52. CheckKey
  53.         call GET_KEY
  54.         cp G_MODE
  55.         ret z
  56.         cp G_1
  57.         jr z, Bit1
  58.         cp G_0               
  59.         jr z, Bit0
  60.         jr ProgLoop
  61.  
  62. Bit1
  63.         scf
  64.         rl      c
  65.         ld      a, '1'
  66.         jr      CheckSnd
  67.  
  68. Bit0
  69.         sla      c
  70.         ld      a, '0'
  71.         jr      CheckSnd
  72.  
  73. CheckSnd:
  74.         ROM_CALL(TX_CHARPUT)
  75.         djnz    ProgLoop
  76.         ld      a, c
  77.         call    PutByte
  78.         ld      a, $FF
  79.         ROM_CALL(TX_CHARPUT)
  80.         jr      Start
  81.  
  82.  
  83.  
  84.  
  85. DispCBin:
  86.         set 3,(IY+05)
  87.         ld      b, 8
  88. DC_NextBit
  89.         rl      c
  90.         jr      nc, DC_Zero
  91.         ld      a, '1'
  92.         jr      DC_Disp 
  93. DC_Zero
  94.         ld      a, '0'
  95. DC_Disp
  96.         ROM_CALL(TX_CHARPUT)
  97.         djnz    DC_NextBit
  98.         res 3,(IY+05)
  99.         ld      a, $FF
  100.         ROM_CALL(TX_CHARPUT)
  101.         ret
  102.  
  103.  
  104.  
  105. ; Thanks for Randy Gluvna (gluvna@home.com) for this recieve routine.
  106.  
  107.  
  108.  
  109. GetByte:
  110.         push bc
  111.         LD      B,008H
  112. R0:
  113.         LD      DE,0FFFFH       
  114.         JR      R2              
  115. R1:
  116.         IN      A,(PORT)        
  117.         AND     003H            
  118.         jr      z, GB_End
  119.         CP      003H            
  120.         JR      NZ,R3           
  121.         IN      A,(PORT)        
  122.         AND     003H            
  123.         jr      z, GB_End
  124.         CP      003H            
  125.         JR      NZ,R3           
  126. R2:
  127.         DEC     DE              
  128.         LD      A,D             
  129.         OR      E               
  130.         JR      NZ,R1           
  131.         jr      GB_End
  132. R3:
  133.         SUB     002H            
  134.         JR      NC,R8           
  135.         LD      A,0D4H          
  136.         OUT     (PORT),A        
  137.         RR      C               
  138.         LD      DE,0FFFFH       
  139. R4:
  140.         IN      A,(PORT)        
  141.         AND     003H            
  142.         CP      002H            
  143.         JR      Z,R5            
  144.         DEC     DE              
  145.         LD      A,D             
  146.         OR      E               
  147.         JR      NZ,R4           
  148.         jr      GB_End
  149. R5:
  150.         LD      A,0C0H          
  151.         OUT     (PORT),A        
  152.         LD      D,004H          
  153. R6:
  154.         DEC     D               
  155.         JR      Z,R7            
  156.         IN      A,(PORT)        
  157.         AND     003H            
  158.         CP      003H            
  159.         JR      NZ,R6           
  160. R7:
  161.         DJNZ    R0              
  162.         LD      A,C             
  163.         jr      GB_End
  164. R8:
  165.         LD      A,0E8H          
  166.         OUT     (PORT),A        
  167.         RR      C               
  168.         LD      DE,0FFFFH       
  169. R9:
  170.         IN      A,(PORT)        
  171.         AND     003H            
  172.         CP      001H            
  173.         JR      Z,R5            
  174.         DEC     DE              
  175.         LD      A,D             
  176.         OR      E               
  177.         JR      NZ,R9           
  178. GB_End
  179.         pop bc
  180.         ret
  181.  
  182.  
  183.  
  184. PutByte:
  185.         push bc
  186.         LD      C,A
  187.         LD      B,8             ; 8 Bits
  188.  
  189. PB_Next_Bit:
  190.  
  191.         LD      A, $C0          ; Set W1 and R1
  192.         OUT     (PORT),A
  193.  
  194. Cont:
  195.         RR      C
  196.         JR      NC, PB_SendZero
  197. PB_SendOne:
  198.         LD      A, $E8
  199.         JR      PB_Output_val
  200. PB_SendZero:
  201.         LD      A, $D4
  202. PB_Output_val:
  203.         OUT     (PORT),A
  204.  
  205.         LD      DE, $FFFF       ; For time-out
  206. PB_Wait_for_W0_and_R0:
  207.         IN      A,(PORT)
  208.         AND     3
  209.         JR      Z, PB_Continue
  210.         IN      A,(PORT)
  211.         AND     3
  212.         JR      Z, PB_Continue
  213.         DEC     DE
  214.         LD      A,D
  215.         OR      E
  216.         JR      NZ, PB_Wait_for_W0_and_R0
  217.         JR      PB_End          ; If error return.
  218.  
  219. PB_Continue:
  220.         LD      A, $C0          ; Set W1 and R1
  221.         OUT     (PORT),A
  222.  
  223.         LD      DE, $FFFF       ; Reload time-out
  224. PB_Wait_for_W1_and_R1:
  225.         DEC     DE
  226.         LD      A,D
  227.         OR      E
  228.         JR      Z, PB_End
  229.         IN      A,(PORT)
  230.         AND     3
  231.         CP      3
  232.         JR      NZ, PB_Wait_for_W1_and_R1
  233.  
  234.         DJNZ    PB_Next_Bit
  235. PB_End:
  236.         LD      A, $C0          ; Set W1 and R1
  237.         OUT     (PORT),A
  238.         POP    BC
  239.         RET
  240.  
  241.  
  242. .end
  243.