Area : ‘奬ë Date : Thu Jun 04, 20:42 From : Dima Orlov 2:461/33.27 To : Segey Pimenov Subj : 24cXX ¯à®ç¨â âì ­ ¤® ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Hello, Segey Pimenov ! > Š®£¤ -â® §¤¥áì ¯à®áª ª¨¢ « ⥪áâ ¯à®á⮩ ¯à®£¨ > ¤«ï ç⥭¨ï á㡦  (­   áª «¥ ¯®-¬®¥¬ã),¥á«¨ ­¥âà㤭®,ª¨­ì⥠¥é¥ > à §. uses CRT; var LPT1: Word; { 24C16 LPT 1ÚÄÄÄÂÄÄÄÂÄÄÄ¿8 ÚÄÄÄÄÄ´A0 ³ E ³VccÃÄÄÄÄÄÄÄÄÄÂÄÄÄÄ>D1 (Pin 3) ³ 2³ ³ E ³ ³7 ÚÁ¿ ³ÚÄÄÄÄ´A1 ³ P ³ WPÃÄÄÄÄÄÄ¿ ³\³15k ³³ 3³ ³ R ³ ³6 ³ ³\³ ³³ÚÄÄÄ´A2 ³ O ³SCLÃÄÄÄ¿ ³ ÀÂÙ ÚÄ>D2 (Pin 4) ³³³ 4³ ³ M ³ ³5 ÀÄÄÅÄÄÅÄÄÙ ³³³ ÚÄ´GND³ ³SDAÃÄÄÂÄÄÄÅÄÄÁÄÄÄÄ>ACK (Pin 10) ³³³ ³ ÀÄÄÄÁÄÄÄÁÄÄÄÙ ³ ³ ³³³ ³ ³/ ª ³ ³³³ ³ ÚÄ´ ³ ³³³ ³ ÚÁ¿³\ í ³ ³³³ ³ ³\³ ³ ³ ³³³ ³ 1k³\³ ³ ³ ÚÄ>D0 (Pin 2) ³³³ ³ ÀÂÙ ³ ³ ³ ³³³ ³ ÀÄÄÄÅÄÄÄÅÄÄÄÄÄÙ ³³³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÁÄÄÄÄÄÄÄ>GND (Pin 25) ³³³ ³³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ>D3 (Pin 5) ³³ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ>D4 (Pin 6) ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ>D5 (Pin 7) } procedure Pause; assembler; asm push ax @@0: jmp @@1 @@1: in al, dx pop ax end; procedure Start; assembler; asm mov dx, lpt1 mov al, 00000110b {Vcc = 1, SCL = 1, SDA = 1} out dx, al call Pause mov al, 00000111b {Vcc = 1, SCL = 1, SDA = 0} out dx, al call Pause mov al, 00000011b {Vcc = 1, SCL = 0, SDA = 0} out dx, al call Pause end; procedure Stop; assembler; asm mov dx, lpt1 mov al, 00000111b {Vcc = 1, SCL = 1, SDA = 0} out dx, al call Pause mov al, 00000110b {Vcc = 1, SCL = 1, SDA = 1} out dx, al call Pause end; function PutByte(B: Byte): boolean; assembler; asm mov dx, lpt1 mov ah, B mov cx, 8 @@0: rcl ah,1 jc @@1 mov al, 00000011b {Vcc = 1, SCL = 0, SDA = 0} out dx, al call Pause mov al, 00000111b {Vcc = 1, SCL = 1, SDA = 0} out dx, al call Pause mov al, 00000011b {Vcc = 1, SCL = 0, SDA = 0} out dx, al jmp @@2 @@1: mov al, 00000010b {Vcc = 1, SCL = 0, SDA = 1} out dx, al call Pause mov al, 00000110b {Vcc = 1, SCL = 1, SDA = 1} out dx, al call Pause mov al, 00000010b {Vcc = 1, SCL = 0, SDA = 1} out dx, al @@2: loop @@0 call Pause mov al, 00000110b {Vcc = 1, SCL = 1, SDA = 1} out dx, al call Pause inc dx in al, dx dec dx and al, 01000000b mov ah, 1 je @@3 mov ah, 0 @@3: mov al, 00000010b {Vcc = 1, SCL = 0, SDA = 1} out dx, al mov al, ah end; function GetByte: byte; assembler; asm mov dx, lpt1 mov cx, 8 @@0: mov al, 00000110b {Vcc = 1, SCL = 1, SDA = 1} out dx, al call Pause inc dx in al, dx dec dx and al, 01000000b shl al,1 shl al,1 rcl ah, 1 mov al, 00000010b {Vcc = 1, SCL = 0, SDA = 1} out dx, al call Pause loop @@0 mov al, 00000110b {Vcc = 1, SCL = 1, SDA = 1} out dx, al call Pause mov al, 00000010b {Vcc = 1, SCL = 0, SDA = 1} out dx, al call Pause mov al, ah end; procedure WriteByte(Addr:Word; B : Byte); begin Start; PutByte($A0 or ((Hi(Addr) shl 1) and $0e)); PutByte(Lo(Addr)); PutByte(B); Stop; Delay(5); end; function ReadByte(Addr:Word): Byte; begin Start; PutByte($A0 or ((Hi(Addr) shl 1) and $0e)); PutByte(Lo(Addr)); Start; PutByte($A1 or ((Hi(Addr) shl 1) and $0e)); ReadByte := GetByte; Stop; end; type TMode = (mError, mWrite, mRead, mHelp); const ModeStr = 'W|R|?'; Modes : Array[0.. Length(ModeStr)] of TMode = (mError, mWrite, mError, mRead, mError, mHelp); var Mode: TMode; FileName: String; procedure AddStr(var S: String; C: Char; Count: Byte); assembler; asm mov cl, Count xor ch, ch jcxz @@1 @@0: les di, S inc byte ptr es:[di] mov al, byte ptr es:[di] xor ah, ah add di, ax mov al, C mov byte ptr es:[di], al loop @@0 @@1: end; procedure ComString; var PComString: ^String; i, j : Byte; Ch: Char; State :(NoOpt, Opt, Ok); MStr: String[12]; begin State := NoOpt; PComString := Ptr(PrefixSeg, $80); i := 1; MStr := ''; while i <= Length(PComString^) do begin Ch := PComString^[i]; case State of NoOpt: if (Ch in ['/', '-']) then begin State := Opt; j := i; end; Opt: if Ch in ['?','A'..'Z', 'a'..'z'] then AddStr(MStr, UpCase(Ch), 1) else State := Ok; end {case}; Inc(i); end; Delete(PComString^, j, Length(MStr) + 1); Mode := Modes[Pos(MStr, ModeStr)]; FileName := ParamStr(1); end; var A, I, Size: Word; Ps: Byte; Buf: Array[0..$7ff] of byte; f: File; begin WriteLn('24C16 reader/writer.'); LPT1 := $378; asm mov dx, lpt1 mov al, 00000110b out dx, al end; ComString; case Mode of mRead: begin Assign(F, FileName); ReWrite(F, 1); if IOResult <> 0 then begin WriteLn('Can''t create file ', FileName); Halt(1); end; Write('Reading '); for i := 0 to $7ff do begin Buf[i] := ReadByte(i); if i mod 50 = 0 then Write('.'); end; BlockWrite(F, Buf, SizeOf(Buf)); Close(F); WriteLn(' Done.'); end; mWrite: begin Assign(F, FileName); Reset(F, 1); if IOResult <> 0 then begin WriteLn('Can''t open file ', FileName); Halt(1); end; BlockRead(F, Buf, SizeOf(Buf), Size); Close(F); if Size > $800 then Size := $800; Write('Writing '); for i := 0 to Size - 1 do begin WriteByte(i, Buf[i]); if i mod 50 = 0 then Write('.'); end; WriteLn(' Done.'); end; mError, mHelp: begin WriteLn('24C16 FileName ', ModeStr); end; end; end. ‘ 㢠¦¥­¨¥¬, „¨¬  Žà«®¢. --- [CONNECT Team] * Origin: Electric mail stantion (2:461/33.27)