;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 4.2.0 #13081 (Linux)
;--------------------------------------------------------
	.module eeprom_io
	.optsdcc -mmcs51 --model-small
	
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
	.globl _i2c_write
	.globl _i2c_read
	.globl _eeprom_read_PARM_4
	.globl _eeprom_read_PARM_3
	.globl _eeprom_read_PARM_2
	.globl _eeprom_read
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
	.area RSEG    (ABS,DATA)
	.org 0x0000
;--------------------------------------------------------
; special function bits
;--------------------------------------------------------
	.area RSEG    (ABS,DATA)
	.org 0x0000
;--------------------------------------------------------
; overlayable register banks
;--------------------------------------------------------
	.area REG_BANK_0	(REL,OVR,DATA)
	.ds 8
;--------------------------------------------------------
; internal ram data
;--------------------------------------------------------
	.area DSEG    (DATA)
_eeprom_read_PARM_2:
	.ds 1
_eeprom_read_PARM_3:
	.ds 2
_eeprom_read_PARM_4:
	.ds 1
;--------------------------------------------------------
; overlayable items in internal ram
;--------------------------------------------------------
;--------------------------------------------------------
; indirectly addressable internal ram data
;--------------------------------------------------------
	.area ISEG    (DATA)
;--------------------------------------------------------
; absolute internal ram data
;--------------------------------------------------------
	.area IABS    (ABS,DATA)
	.area IABS    (ABS,DATA)
;--------------------------------------------------------
; bit data
;--------------------------------------------------------
	.area BSEG    (BIT)
;--------------------------------------------------------
; paged external ram data
;--------------------------------------------------------
	.area PSEG    (PAG,XDATA)
;--------------------------------------------------------
; external ram data
;--------------------------------------------------------
	.area XSEG    (XDATA)
_eeprom_read_cmd_65536_8:
	.ds 1
;--------------------------------------------------------
; absolute external ram data
;--------------------------------------------------------
	.area XABS    (ABS,XDATA)
;--------------------------------------------------------
; external initialized ram data
;--------------------------------------------------------
	.area HOME    (CODE)
	.area GSINIT0 (CODE)
	.area GSINIT1 (CODE)
	.area GSINIT2 (CODE)
	.area GSINIT3 (CODE)
	.area GSINIT4 (CODE)
	.area GSINIT5 (CODE)
	.area GSINIT  (CODE)
	.area GSFINAL (CODE)
	.area CSEG    (CODE)
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
	.area HOME    (CODE)
	.area GSINIT  (CODE)
	.area GSFINAL (CODE)
	.area GSINIT  (CODE)
;--------------------------------------------------------
; Home
;--------------------------------------------------------
	.area HOME    (CODE)
	.area HOME    (CODE)
;--------------------------------------------------------
; code
;--------------------------------------------------------
	.area CSEG    (CODE)
;------------------------------------------------------------
;Allocation info for local variables in function 'eeprom_read'
;------------------------------------------------------------
;eeprom_offset             Allocated with name '_eeprom_read_PARM_2'
;buf                       Allocated with name '_eeprom_read_PARM_3'
;len                       Allocated with name '_eeprom_read_PARM_4'
;i2c_addr                  Allocated to registers r7 
;cmd                       Allocated with name '_eeprom_read_cmd_65536_8'
;------------------------------------------------------------
;	eeprom_io.c:29: eeprom_read (unsigned char i2c_addr, unsigned char eeprom_offset,
;	-----------------------------------------
;	 function eeprom_read
;	-----------------------------------------
_eeprom_read:
	ar7 = 0x07
	ar6 = 0x06
	ar5 = 0x05
	ar4 = 0x04
	ar3 = 0x03
	ar2 = 0x02
	ar1 = 0x01
	ar0 = 0x00
	mov	r7,dpl
;	eeprom_io.c:36: cmd[0] = eeprom_offset;
	mov	dptr,#_eeprom_read_cmd_65536_8
	mov	a,_eeprom_read_PARM_2
	movx	@dptr,a
;	eeprom_io.c:37: if (!i2c_write(i2c_addr, cmd, 1))
	mov	_i2c_write_PARM_2,#_eeprom_read_cmd_65536_8
	mov	(_i2c_write_PARM_2 + 1),#(_eeprom_read_cmd_65536_8 >> 8)
	mov	_i2c_write_PARM_3,#0x01
	mov	dpl,r7
	push	ar7
	lcall	_i2c_write
	mov	a,dpl
	pop	ar7
;	eeprom_io.c:38: return 0;
	jnz	00102$
	mov	dpl,a
	ret
00102$:
;	eeprom_io.c:40: return i2c_read(i2c_addr, buf, len);
	mov	_i2c_read_PARM_2,_eeprom_read_PARM_3
	mov	(_i2c_read_PARM_2 + 1),(_eeprom_read_PARM_3 + 1)
	mov	_i2c_read_PARM_3,_eeprom_read_PARM_4
	mov	dpl,r7
;	eeprom_io.c:41: }
	ljmp	_i2c_read
	.area CSEG    (CODE)
	.area CONST   (CODE)
	.area CABS    (ABS,CODE)
