home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / z / zsim20.zip / PORTIO.ASM < prev    next >
Assembly Source File  |  1992-12-02  |  1KB  |  73 lines

  1.  
  2. PUBLIC PORT_IN,PORT_OUT,GET_RAND   ; FAR Routinen
  3.  
  4. PortIOCode segment para 'CODE'
  5.  
  6. assume  cs:PortIOCode,ds:nothing,es:nothing,ss:nothing
  7.  
  8.  
  9. ; die Routinen sind als FAR Routinen implementiert, da sie
  10. ; moeglicherweise vom Benutzer veraendert werden koennen. Dabei
  11. ; soll er aber moeglichst nichts von der inneren Struktur der anderen
  12. ; Module mitbekommen, so auch keine Segmentnamen
  13.  
  14. ; !
  15. ; es durfen keine Register zerstoert werden !
  16. ; !
  17.  
  18. DummyOps equ 1
  19.  
  20. ;
  21. ; AL:=port(DX)
  22. ;
  23.  
  24. PORT_IN proc far
  25.  
  26.   if DummyOps
  27.  
  28.         mov al,0ffh           ; alles auf high
  29.   else
  30.         in al,dx            ; wenn nicht dummy
  31.   endif
  32.  
  33.         ret
  34. PORT_IN endp
  35.  
  36. ;
  37. ; port(DX):=AL
  38. ;
  39.  
  40. PORT_OUT proc far
  41.  
  42.   if DummyOps
  43.         nop
  44.   else
  45.         out dx,al           ; wenn nicht dummy
  46.   endif
  47.         ret
  48. PORT_OUT endp
  49.  
  50. ;
  51. ; AL:= "Zufallszahl" x, 0<=x<=127
  52. ;
  53. GET_RAND proc far
  54.      push cx
  55.      push dx
  56.      mov al,ah
  57.      mov ah,2ch                   ; MsDos Get Time
  58.      int 21h
  59.      mov  ah,al
  60.      mov  al,ch
  61.      xor  al,cl
  62.      xor  al,dh
  63.      xor  al,dl
  64.      and  al,7fh
  65.      pop  dx
  66.      pop  cx
  67.      ret
  68. GET_RAND endp
  69.  
  70. PortIOCode ends
  71.  
  72. end
  73.