home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ENTERPRS / CPM / UTILS / S / SGTOOL10.ARC / VDCASM.C < prev    next >
Text File  |  1993-07-19  |  1KB  |  55 lines

  1. /*
  2. SG C Tools 1.0
  3.  
  4. (C) 1993 Steve Goldsmith
  5. All Rights Reserved
  6.  
  7. VDCASM.C is in-line Z80 Assembler code to speed up invdc() and outvdc().
  8. I encountered a compiler lock up tring to optimize (-O) VDC.C with this code.
  9. I used C -O -C VDC.C to compile.  Works fine without -O, go figure?  Just
  10. replace the code in VDC.C with the code below.  If you can figure out why this
  11. is bombing the optimizer let me know!  Even without -O the Assembler code is
  12. faster than inp() and outp()!
  13.  
  14. Compiled with HI-TECH C 3.09 (CP/M-80).
  15. */
  16.  
  17. uchar invdc(uchar RegNum)
  18. {
  19.  
  20. /* in-line assembler to set vdc reg to read and wait for status bit 7 */
  21.  
  22. #asm
  23.         ld      a,(ix+6)
  24.         ld      bc,0d600h
  25.         out     (c),a
  26. 1:
  27.         in      a,(c)
  28.         bit     7,a
  29.         jr      z,1b
  30. #endasm
  31.  
  32.   return(inp(vdcDataReg));                    /* read register */
  33. }
  34.  
  35. void outvdc(uchar RegNum, uchar RegVal)
  36. {
  37.  
  38. /* in-line assembler to set vdc reg to write, wait for status bit 7 and */
  39. /* write new value to reg */
  40.  
  41. #asm
  42.         ld      a,(ix+6)
  43.         ld      bc,0d600h
  44.         out     (c),a
  45. 1:
  46.         in      a,(c)
  47.         bit     7,a
  48.         jr      z,1b
  49.         ld      a,(ix+8)
  50.         inc     bc
  51.         out     (c),a
  52. #endasm
  53.  
  54. }
  55.