Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199609.adf » Regulars » MikeC/IICRam2

MikeC/IICRam2

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199609.adf » Regulars
Filename: MikeC/IICRam2
Read OK:
File size: 065E bytes
Load address: 0000
Exec address: 0000
File contents
   10REM> IICRam2
   20CLS
   30PRINT "Routines to Read and Write"
   40PRINT "EEPROM of device at &A8"
   50PRINT "By Mike Cook"
   60DIM PBK% 256
   70REPEAT
   80PRINT"1 - Write to PROM"
   90PRINT"2 - Read from PROM"
  100A$=GET$
  110IF A$="1" THEN PROCgetData
  120IF A$="2" THEN PROCgetAdd
  130UNTIL FALSE
  140END
  150DEF PROCgetData
  160INPUT"Address to write to 0-511 ",Ad%
  170INPUT"Number of bytes to write ",N%
  180IF Ad%<256 AND Ad%+N%>256 THEN PRINT"Over bank boundry just reading ";255-Ad%;" bytes" : N%=Ad%-256
  190B%= (Ad% AND 256)>>8
  200FOR A%=1 TO N%
  210PRINT"Address ";Ad%+A%-1;" ";
  220INPUT T%
  230PBK%?(A%-1)=T%
  240NEXT
  250PROC_Write(PBK%,Ad%,N%,B%)
  260ENDPROC
  270
  280DEF PROCgetAdd
  290INPUT"Address to read from 0-511 ",Ad%
  300INPUT"Number of bytes to read ",N%
  310IF Ad%<256 AND Ad%+N%>256 THEN PRINT"Over bank boundry just reading ";255-Ad%;" bytes" : N%=Ad%-256
  320B%= (Ad% AND 256)>>8
  330PROC_Read(Ad%,N%,B%)
  340ENDPROC
  350
  360REM The procedures that do all the work
  370DEF PROC_Write(Sadd%,Add%,Num%,Bank%)
  380DIM Sbuf% 9
  390REM Add% Is the PROM address, Num% is the number of bytes to send
  400REM Bank% is the upper or lower bank of memory
  410LOCAL A%,Ea%
  420Ea%=&A8 OR (Bank% AND 1)<<1 :REM Put Bank% bit into BA of slave address
  430REM Write in chunks of 8 bytes
  440B%=0
  450REPEAT
  460?Sbuf%=Add%+B%
  470Sbuf%?1=Sadd%?B%
  480B%+=1
  490Num%-=1
  500SYS "IIC_Control",Ea%,Sbuf%,2
  510
  520REM Delay to allow write to take place
  530T=TIME+1
  540REPEAT UNTIL TIME>T
  550UNTIL Num%=0
  560ENDPROC
  570
  580DEF PROC_Read(Add%,Num%,Bank%)
  590DIM Rx% 258
  600LOCAL A%,Ea%
  610Ea%=&A8 OR (Bank% AND 1)<<1 :REM Put Bank% bit into BA of slave address
  620Num%=Num% AND 255
  630?Rx%=Add% :REM Set Read point
  640SYS "IIC_Control",Ea%,Rx%,1
  650REM Read the locations
  660SYS "IIC_Control",Ea% OR 1,Rx%,Num%
  670FOR A%=0 TO Num%-1
  680PRINT"Address ";Add%+A%;" contents ";Rx%?A%
  690NEXT
  700PRINT
  710ENDPROC

�> IICRam2
�
"� "Routines to Read and Write"
(� "EEPROM of device at &A8"
2� "By Mike Cook"
<� PBK% 256
F�
P�"1 - Write to PROM"
Z�"2 - Read from PROM"
dA$=�
n� A$="1" � �getData
x� A$="2" � �getAdd
�� �
��
�� �getData
�%�"Address to write to 0-511 ",Ad%
�#�"Number of bytes to write ",N%
�]� Ad%<256 � Ad%+N%>256 � �"Over bank boundry just reading ";255-Ad%;" bytes" : N%=Ad%-256
�B%= (Ad% � 256)>>8
�� A%=1 � N%
��"Address ";Ad%+A%-1;" ";
�� T%
�PBK%?(A%-1)=T%
��
��_Write(PBK%,Ad%,N%,B%)
�


� �getAdd
"&�"Address to read from 0-511 ",Ad%
,"�"Number of bytes to read ",N%
6]� Ad%<256 � Ad%+N%>256 � �"Over bank boundry just reading ";255-Ad%;" bytes" : N%=Ad%-256
@B%= (Ad% � 256)>>8
J�_Read(Ad%,N%,B%)
T�
^
h)� The procedures that do all the work
r$� �_Write(Sadd%,Add%,Num%,Bank%)
|
� Sbuf% 9
�C� Add% Is the PROM address, Num% is the number of bytes to send
�0� Bank% is the upper or lower bank of memory
�� A%,Ea%
�FEa%=&A8 � (Bank% � 1)<<1 :� Put Bank% bit into BA of slave address
� � Write in chunks of 8 bytes
�B%=0
��
�?Sbuf%=Add%+B%
�Sbuf%?1=Sadd%?B%
�	B%+=1
�Num%-=1
� ș "IIC_Control",Ea%,Sbuf%,2
�
(� Delay to allow write to take place
	T=�+1
� � �>T
&� Num%=0
0�
:
D� �_Read(Add%,Num%,Bank%)
N
� Rx% 258
X� A%,Ea%
bFEa%=&A8 � (Bank% � 1)<<1 :� Put Bank% bit into BA of slave address
lNum%=Num% � 255
v?Rx%=Add% :� Set Read point
�ș "IIC_Control",Ea%,Rx%,1
�� Read the locations
�%ș "IIC_Control",Ea% � 1,Rx%,Num%
�� A%=0 � Num%-1
�+�"Address ";Add%+A%;" contents ";Rx%?A%
��
��
��
�
00000000  0d 00 0a 0e f4 3e 20 49  49 43 52 61 6d 32 0d 00  |.....> IICRam2..|
00000010  14 05 db 0d 00 1e 22 f1  20 22 52 6f 75 74 69 6e  |......". "Routin|
00000020  65 73 20 74 6f 20 52 65  61 64 20 61 6e 64 20 57  |es to Read and W|
00000030  72 69 74 65 22 0d 00 28  1f f1 20 22 45 45 50 52  |rite"..(.. "EEPR|
00000040  4f 4d 20 6f 66 20 64 65  76 69 63 65 20 61 74 20  |OM of device at |
00000050  26 41 38 22 0d 00 32 14  f1 20 22 42 79 20 4d 69  |&A8"..2.. "By Mi|
00000060  6b 65 20 43 6f 6f 6b 22  0d 00 3c 0e de 20 50 42  |ke Cook"..<.. PB|
00000070  4b 25 20 32 35 36 0d 00  46 05 f5 0d 00 50 18 f1  |K% 256..F....P..|
00000080  22 31 20 2d 20 57 72 69  74 65 20 74 6f 20 50 52  |"1 - Write to PR|
00000090  4f 4d 22 0d 00 5a 19 f1  22 32 20 2d 20 52 65 61  |OM"..Z.."2 - Rea|
000000a0  64 20 66 72 6f 6d 20 50  52 4f 4d 22 0d 00 64 08  |d from PROM"..d.|
000000b0  41 24 3d be 0d 00 6e 17  e7 20 41 24 3d 22 31 22  |A$=...n.. A$="1"|
000000c0  20 8c 20 f2 67 65 74 44  61 74 61 0d 00 78 16 e7  | . .getData..x..|
000000d0  20 41 24 3d 22 32 22 20  8c 20 f2 67 65 74 41 64  | A$="2" . .getAd|
000000e0  64 0d 00 82 07 fd 20 a3  0d 00 8c 05 e0 0d 00 96  |d..... .........|
000000f0  0e dd 20 f2 67 65 74 44  61 74 61 0d 00 a0 25 e8  |.. .getData...%.|
00000100  22 41 64 64 72 65 73 73  20 74 6f 20 77 72 69 74  |"Address to writ|
00000110  65 20 74 6f 20 30 2d 35  31 31 20 22 2c 41 64 25  |e to 0-511 ",Ad%|
00000120  0d 00 aa 23 e8 22 4e 75  6d 62 65 72 20 6f 66 20  |...#."Number of |
00000130  62 79 74 65 73 20 74 6f  20 77 72 69 74 65 20 22  |bytes to write "|
00000140  2c 4e 25 0d 00 b4 5d e7  20 41 64 25 3c 32 35 36  |,N%...]. Ad%<256|
00000150  20 80 20 41 64 25 2b 4e  25 3e 32 35 36 20 8c 20  | . Ad%+N%>256 . |
00000160  f1 22 4f 76 65 72 20 62  61 6e 6b 20 62 6f 75 6e  |."Over bank boun|
00000170  64 72 79 20 6a 75 73 74  20 72 65 61 64 69 6e 67  |dry just reading|
00000180  20 22 3b 32 35 35 2d 41  64 25 3b 22 20 62 79 74  | ";255-Ad%;" byt|
00000190  65 73 22 20 3a 20 4e 25  3d 41 64 25 2d 32 35 36  |es" : N%=Ad%-256|
000001a0  0d 00 be 16 42 25 3d 20  28 41 64 25 20 80 20 32  |....B%= (Ad% . 2|
000001b0  35 36 29 3e 3e 38 0d 00  c8 0f e3 20 41 25 3d 31  |56)>>8..... A%=1|
000001c0  20 b8 20 4e 25 0d 00 d2  1d f1 22 41 64 64 72 65  | . N%....."Addre|
000001d0  73 73 20 22 3b 41 64 25  2b 41 25 2d 31 3b 22 20  |ss ";Ad%+A%-1;" |
000001e0  22 3b 0d 00 dc 08 e8 20  54 25 0d 00 e6 12 50 42  |";..... T%....PB|
000001f0  4b 25 3f 28 41 25 2d 31  29 3d 54 25 0d 00 f0 05  |K%?(A%-1)=T%....|
00000200  ed 0d 00 fa 1b f2 5f 57  72 69 74 65 28 50 42 4b  |......_Write(PBK|
00000210  25 2c 41 64 25 2c 4e 25  2c 42 25 29 0d 01 04 05  |%,Ad%,N%,B%)....|
00000220  e1 0d 01 0e 04 0d 01 18  0d dd 20 f2 67 65 74 41  |.......... .getA|
00000230  64 64 0d 01 22 26 e8 22  41 64 64 72 65 73 73 20  |dd.."&."Address |
00000240  74 6f 20 72 65 61 64 20  66 72 6f 6d 20 30 2d 35  |to read from 0-5|
00000250  31 31 20 22 2c 41 64 25  0d 01 2c 22 e8 22 4e 75  |11 ",Ad%..,"."Nu|
00000260  6d 62 65 72 20 6f 66 20  62 79 74 65 73 20 74 6f  |mber of bytes to|
00000270  20 72 65 61 64 20 22 2c  4e 25 0d 01 36 5d e7 20  | read ",N%..6]. |
00000280  41 64 25 3c 32 35 36 20  80 20 41 64 25 2b 4e 25  |Ad%<256 . Ad%+N%|
00000290  3e 32 35 36 20 8c 20 f1  22 4f 76 65 72 20 62 61  |>256 . ."Over ba|
000002a0  6e 6b 20 62 6f 75 6e 64  72 79 20 6a 75 73 74 20  |nk boundry just |
000002b0  72 65 61 64 69 6e 67 20  22 3b 32 35 35 2d 41 64  |reading ";255-Ad|
000002c0  25 3b 22 20 62 79 74 65  73 22 20 3a 20 4e 25 3d  |%;" bytes" : N%=|
000002d0  41 64 25 2d 32 35 36 0d  01 40 16 42 25 3d 20 28  |Ad%-256..@.B%= (|
000002e0  41 64 25 20 80 20 32 35  36 29 3e 3e 38 0d 01 4a  |Ad% . 256)>>8..J|
000002f0  15 f2 5f 52 65 61 64 28  41 64 25 2c 4e 25 2c 42  |.._Read(Ad%,N%,B|
00000300  25 29 0d 01 54 05 e1 0d  01 5e 04 0d 01 68 29 f4  |%)..T....^...h).|
00000310  20 54 68 65 20 70 72 6f  63 65 64 75 72 65 73 20  | The procedures |
00000320  74 68 61 74 20 64 6f 20  61 6c 6c 20 74 68 65 20  |that do all the |
00000330  77 6f 72 6b 0d 01 72 24  dd 20 f2 5f 57 72 69 74  |work..r$. ._Writ|
00000340  65 28 53 61 64 64 25 2c  41 64 64 25 2c 4e 75 6d  |e(Sadd%,Add%,Num|
00000350  25 2c 42 61 6e 6b 25 29  0d 01 7c 0d de 20 53 62  |%,Bank%)..|.. Sb|
00000360  75 66 25 20 39 0d 01 86  43 f4 20 41 64 64 25 20  |uf% 9...C. Add% |
00000370  49 73 20 74 68 65 20 50  52 4f 4d 20 61 64 64 72  |Is the PROM addr|
00000380  65 73 73 2c 20 4e 75 6d  25 20 69 73 20 74 68 65  |ess, Num% is the|
00000390  20 6e 75 6d 62 65 72 20  6f 66 20 62 79 74 65 73  | number of bytes|
000003a0  20 74 6f 20 73 65 6e 64  0d 01 90 30 f4 20 42 61  | to send...0. Ba|
000003b0  6e 6b 25 20 69 73 20 74  68 65 20 75 70 70 65 72  |nk% is the upper|
000003c0  20 6f 72 20 6c 6f 77 65  72 20 62 61 6e 6b 20 6f  | or lower bank o|
000003d0  66 20 6d 65 6d 6f 72 79  0d 01 9a 0c ea 20 41 25  |f memory..... A%|
000003e0  2c 45 61 25 0d 01 a4 46  45 61 25 3d 26 41 38 20  |,Ea%...FEa%=&A8 |
000003f0  84 20 28 42 61 6e 6b 25  20 80 20 31 29 3c 3c 31  |. (Bank% . 1)<<1|
00000400  20 3a f4 20 50 75 74 20  42 61 6e 6b 25 20 62 69  | :. Put Bank% bi|
00000410  74 20 69 6e 74 6f 20 42  41 20 6f 66 20 73 6c 61  |t into BA of sla|
00000420  76 65 20 61 64 64 72 65  73 73 0d 01 ae 20 f4 20  |ve address... . |
00000430  57 72 69 74 65 20 69 6e  20 63 68 75 6e 6b 73 20  |Write in chunks |
00000440  6f 66 20 38 20 62 79 74  65 73 0d 01 b8 08 42 25  |of 8 bytes....B%|
00000450  3d 30 0d 01 c2 05 f5 0d  01 cc 12 3f 53 62 75 66  |=0.........?Sbuf|
00000460  25 3d 41 64 64 25 2b 42  25 0d 01 d6 14 53 62 75  |%=Add%+B%....Sbu|
00000470  66 25 3f 31 3d 53 61 64  64 25 3f 42 25 0d 01 e0  |f%?1=Sadd%?B%...|
00000480  09 42 25 2b 3d 31 0d 01  ea 0b 4e 75 6d 25 2d 3d  |.B%+=1....Num%-=|
00000490  31 0d 01 f4 20 c8 99 20  22 49 49 43 5f 43 6f 6e  |1... .. "IIC_Con|
000004a0  74 72 6f 6c 22 2c 45 61  25 2c 53 62 75 66 25 2c  |trol",Ea%,Sbuf%,|
000004b0  32 0d 01 fe 04 0d 02 08  28 f4 20 44 65 6c 61 79  |2.......(. Delay|
000004c0  20 74 6f 20 61 6c 6c 6f  77 20 77 72 69 74 65 20  | to allow write |
000004d0  74 6f 20 74 61 6b 65 20  70 6c 61 63 65 0d 02 12  |to take place...|
000004e0  09 54 3d 91 2b 31 0d 02  1c 0b f5 20 fd 20 91 3e  |.T=.+1..... . .>|
000004f0  54 0d 02 26 0c fd 20 4e  75 6d 25 3d 30 0d 02 30  |T..&.. Num%=0..0|
00000500  05 e1 0d 02 3a 04 0d 02  44 1d dd 20 f2 5f 52 65  |....:...D.. ._Re|
00000510  61 64 28 41 64 64 25 2c  4e 75 6d 25 2c 42 61 6e  |ad(Add%,Num%,Ban|
00000520  6b 25 29 0d 02 4e 0d de  20 52 78 25 20 32 35 38  |k%)..N.. Rx% 258|
00000530  0d 02 58 0c ea 20 41 25  2c 45 61 25 0d 02 62 46  |..X.. A%,Ea%..bF|
00000540  45 61 25 3d 26 41 38 20  84 20 28 42 61 6e 6b 25  |Ea%=&A8 . (Bank%|
00000550  20 80 20 31 29 3c 3c 31  20 3a f4 20 50 75 74 20  | . 1)<<1 :. Put |
00000560  42 61 6e 6b 25 20 62 69  74 20 69 6e 74 6f 20 42  |Bank% bit into B|
00000570  41 20 6f 66 20 73 6c 61  76 65 20 61 64 64 72 65  |A of slave addre|
00000580  73 73 0d 02 6c 13 4e 75  6d 25 3d 4e 75 6d 25 20  |ss..l.Num%=Num% |
00000590  80 20 32 35 35 0d 02 76  1f 3f 52 78 25 3d 41 64  |. 255..v.?Rx%=Ad|
000005a0  64 25 20 3a f4 20 53 65  74 20 52 65 61 64 20 70  |d% :. Set Read p|
000005b0  6f 69 6e 74 0d 02 80 1e  c8 99 20 22 49 49 43 5f  |oint...... "IIC_|
000005c0  43 6f 6e 74 72 6f 6c 22  2c 45 61 25 2c 52 78 25  |Control",Ea%,Rx%|
000005d0  2c 31 0d 02 8a 18 f4 20  52 65 61 64 20 74 68 65  |,1..... Read the|
000005e0  20 6c 6f 63 61 74 69 6f  6e 73 0d 02 94 25 c8 99  | locations...%..|
000005f0  20 22 49 49 43 5f 43 6f  6e 74 72 6f 6c 22 2c 45  | "IIC_Control",E|
00000600  61 25 20 84 20 31 2c 52  78 25 2c 4e 75 6d 25 0d  |a% . 1,Rx%,Num%.|
00000610  02 9e 13 e3 20 41 25 3d  30 20 b8 20 4e 75 6d 25  |.... A%=0 . Num%|
00000620  2d 31 0d 02 a8 2b f1 22  41 64 64 72 65 73 73 20  |-1...+."Address |
00000630  22 3b 41 64 64 25 2b 41  25 3b 22 20 63 6f 6e 74  |";Add%+A%;" cont|
00000640  65 6e 74 73 20 22 3b 52  78 25 3f 41 25 0d 02 b2  |ents ";Rx%?A%...|
00000650  05 ed 0d 02 bc 05 f1 0d  02 c6 05 e1 0d ff        |..............|
0000065e