;--------------------------------------------------------
; File Created by SDCC : FreeWare ANSI-C Compiler
; Version 2.6.1 #4330 (Oct 18 2006)
; This file generated Wed Oct 18 23:31:23 2006
;--------------------------------------------------------
	.module gets
	.optsdcc -mhc08
	
	.area HOME (CODE)
	.area GSINIT0 (CODE)
	.area GSINIT (CODE)
	.area GSFINAL (CODE)
	.area CSEG (CODE)
	.area XINIT
	.area CONST   (CODE)
	.area DSEG
	.area OSEG    (OVR)
	.area BSEG
	.area XSEG
	.area XISEG
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
	.globl _gets
;--------------------------------------------------------
;  ram data
;--------------------------------------------------------
	.area DSEG
;--------------------------------------------------------
; overlayable items in  ram 
;--------------------------------------------------------
	.area OSEG    (OVR)
;--------------------------------------------------------
; external initialized ram data
;--------------------------------------------------------
	.area XISEG
;--------------------------------------------------------
; extended address mode data
;--------------------------------------------------------
	.area XSEG
_gets_str_1_1:
	.ds 2
_gets_s_1_1:
	.ds 2
_gets_c_1_1:
	.ds 1
_gets_count_1_1:
	.ds 2
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
	.area HOME (CODE)
	.area GSINIT (CODE)
	.area GSFINAL (CODE)
	.area GSINIT (CODE)
;--------------------------------------------------------
; Home
;--------------------------------------------------------
	.area HOME (CODE)
	.area CSEG (CODE)
;--------------------------------------------------------
; code
;--------------------------------------------------------
	.area CSEG (CODE)
;------------------------------------------------------------
;Allocation info for local variables in function 'gets'
;------------------------------------------------------------
;str                       Allocated with name '_gets_str_1_1'
;s                         Allocated with name '_gets_s_1_1'
;c                         Allocated with name '_gets_c_1_1'
;count                     Allocated with name '_gets_count_1_1'
;------------------------------------------------------------
;gets.c:3: char * gets(const char *str) {
;	-----------------------------------------
;	 function gets
;	-----------------------------------------
_gets:
;     genReceive
;     loadRegFromAop (a, REG(-,-,-,a), 0)
; transferRegReg(a,a)
;     storeRegToAop (a, EXT(_gets_str_1_1), 0), stacked=0, isaddr=0
	sta	(_gets_str_1_1 + 1)
;     loadRegFromAop (x, REG(-,-,-,x), 0)
; transferRegReg(x,x)
;     storeRegToAop (x, EXT(_gets_str_1_1), 1), stacked=0, isaddr=0
	stx	_gets_str_1_1
;gets.c:4: char *s=str;
;     genAssign
;     loadRegFromAop (a, EXT(_gets_str_1_1), 1)
	lda	_gets_str_1_1
;     storeRegToAop (a, EXT(_gets_s_1_1), 1), stacked=0, isaddr=0
	sta	_gets_s_1_1
;     loadRegFromAop (a, EXT(_gets_str_1_1), 0)
	lda	(_gets_str_1_1 + 1)
;     storeRegToAop (a, EXT(_gets_s_1_1), 0), stacked=0, isaddr=0
	sta	(_gets_s_1_1 + 1)
;gets.c:6: unsigned int count=0;
;     genAssign
;     loadRegFromAop (a, LIT(#0x00), 1)
;     storeRegToAop (a, EXT(_gets_count_1_1), 1), stacked=0, isaddr=0
;     loadRegFromAop (a, LIT(#0x00), 0)
;     storeRegToAop (a, EXT(_gets_count_1_1), 0), stacked=0, isaddr=0
; Peephole 5c   - eliminated redundant clra
	clra
	sta	_gets_count_1_1
	sta	(_gets_count_1_1 + 1)
;gets.c:8: while (1) {
00109$:
;gets.c:9: c=getchar();
;     genCall
	jsr	_getchar
;     loadRegFromAop (a, REG(-,-,-,a), 0)
; transferRegReg(a,a)
;     storeRegToAop (a, EXT(_gets_c_1_1), 0), stacked=0, isaddr=0
	sta	_gets_c_1_1
;gets.c:10: switch(c) {
;     genCmpEQorNE	(==)
;     loadRegFromAop (a, EXT(_gets_c_1_1), 0)
	lda	_gets_c_1_1
	cmp	#0x08
; Peephole 2d	- eliminated jmp
	beq	00101$
00118$:
;     genCmpEQorNE	(==)
;     loadRegFromAop (a, EXT(_gets_c_1_1), 0)
	lda	_gets_c_1_1
	cmp	#0x0A
; Peephole 2d	- eliminated jmp
	beq	00105$
00119$:
;     genCmpEQorNE	(==)
;     loadRegFromAop (a, EXT(_gets_c_1_1), 0)
	lda	_gets_c_1_1
	cmp	#0x0D
; Peephole 2d	- eliminated jmp
	beq	00105$
00120$:
; Peephole 3	- shortened jmp to bra
	bra	00106$
;gets.c:11: case '\b': // backspace
00101$:
;gets.c:12: if (count) {
;     genIfx
;     loadRegFromAop (a, EXT(_gets_count_1_1), 0)
	lda	(_gets_count_1_1 + 1)
	ora	_gets_count_1_1
;     genIfxJump
; Peephole 2d	- eliminated jmp
	beq	00109$
00121$:
;gets.c:13: putchar ('\b');
;     genCall
;     loadRegFromAop (a, LIT(#0x08), 0)
	lda	#0x08
;     storeRegToAop (a, REG(-,-,-,a), 0), stacked=0, isaddr=0
; transferRegReg(a,a)
	jsr	_putchar
;gets.c:14: putchar (' ');
;     genCall
;     loadRegFromAop (a, LIT(#0x20), 0)
	lda	#0x20
;     storeRegToAop (a, REG(-,-,-,a), 0), stacked=0, isaddr=0
; transferRegReg(a,a)
	jsr	_putchar
;gets.c:15: putchar ('\b');
;     genCall
;     loadRegFromAop (a, LIT(#0x08), 0)
	lda	#0x08
;     storeRegToAop (a, REG(-,-,-,a), 0), stacked=0, isaddr=0
; transferRegReg(a,a)
	jsr	_putchar
;gets.c:16: s--;
;     genMinus
;     loadRegFromAop (a, EXT(_gets_s_1_1), 0)
	lda	(_gets_s_1_1 + 1)
	sub	#0x01
;     storeRegToAop (a, EXT(_gets_s_1_1), 0), stacked=0, isaddr=0
	sta	(_gets_s_1_1 + 1)
;     loadRegFromAop (a, EXT(_gets_s_1_1), 1)
	lda	_gets_s_1_1
	sbc	#0x00
;     storeRegToAop (a, EXT(_gets_s_1_1), 1), stacked=0, isaddr=0
	sta	_gets_s_1_1
;gets.c:17: count--;
;     genMinus
;     loadRegFromAop (a, EXT(_gets_count_1_1), 0)
	lda	(_gets_count_1_1 + 1)
	sub	#0x01
;     storeRegToAop (a, EXT(_gets_count_1_1), 0), stacked=0, isaddr=0
	sta	(_gets_count_1_1 + 1)
;     loadRegFromAop (a, EXT(_gets_count_1_1), 1)
	lda	_gets_count_1_1
	sbc	#0x00
;     storeRegToAop (a, EXT(_gets_count_1_1), 1), stacked=0, isaddr=0
	sta	_gets_count_1_1
;gets.c:19: break;
; Peephole 3	- shortened jmp to bra
	bra	00109$
;gets.c:21: case '\r': // CR or LF
00105$:
;gets.c:22: putchar('\r');
;     genCall
;     loadRegFromAop (a, LIT(#0x0D), 0)
	lda	#0x0D
;     storeRegToAop (a, REG(-,-,-,a), 0), stacked=0, isaddr=0
; transferRegReg(a,a)
	jsr	_putchar
;gets.c:23: putchar('\n');
;     genCall
;     loadRegFromAop (a, LIT(#0x0A), 0)
	lda	#0x0A
;     storeRegToAop (a, REG(-,-,-,a), 0), stacked=0, isaddr=0
; transferRegReg(a,a)
	jsr	_putchar
;gets.c:24: *s=0;
;     genPointerSet
;     loadRegFromAop (hx, EXT(_gets_s_1_1), 0)
;     loadRegFromAop (a, EXT(_gets_s_1_1), 1)
	lda	_gets_s_1_1
;     loadRegFromAop (x, EXT(_gets_s_1_1), 0)
	ldx	(_gets_s_1_1 + 1)
; transferRegReg(a,h)
	psha
	pulh
;     loadRegFromAop (a, LIT(#0x00), 0)
	clra
	sta	,x
;gets.c:25: return str;
;     genRet
;     loadRegFromAop (x, EXT(_gets_str_1_1), 1)
	ldx	_gets_str_1_1
;     storeRegToAop (x, REG(-,-,-,x), 0), stacked=0, isaddr=0
; transferRegReg(x,x)
;     loadRegFromAop (a, EXT(_gets_str_1_1), 0)
	lda	(_gets_str_1_1 + 1)
;     storeRegToAop (a, REG(-,-,-,a), 0), stacked=0, isaddr=0
; transferRegReg(a,a)
; Peephole 3	- shortened jmp to bra
; Peephole 6b  - replaced jmp to rts with rts
	rts
;gets.c:26: default:
00106$:
;gets.c:27: *s++=c;
;     genPointerSet
;     loadRegFromAop (hx, EXT(_gets_s_1_1), 0)
;     loadRegFromAop (a, EXT(_gets_s_1_1), 1)
	lda	_gets_s_1_1
;     loadRegFromAop (x, EXT(_gets_s_1_1), 0)
	ldx	(_gets_s_1_1 + 1)
; transferRegReg(a,h)
	psha
	pulh
;     loadRegFromAop (a, EXT(_gets_c_1_1), 0)
	lda	_gets_c_1_1
	sta	,x
	aix	#1
;     storeRegToAop (hx, EXT(_gets_s_1_1), 0), stacked=0, isaddr=0
; transferRegReg(h,a)
	pshh
	pula
;     storeRegToAop (a, EXT(_gets_s_1_1), 1), stacked=0, isaddr=0
	sta	_gets_s_1_1
;     storeRegToAop (x, EXT(_gets_s_1_1), 0), stacked=0, isaddr=0
	stx	(_gets_s_1_1 + 1)
;gets.c:28: count++;
; checking lic
; checking IS_ITEMP
; pset=0, pget=0
;     genPlus
; IS_AOP_HX = 0
; icount = 1, sameRegs=1
;     genPlusIncr
;     loadRegFromAop (a, EXT(_gets_count_1_1), 0)
	lda	(_gets_count_1_1 + 1)
	inca
;     storeRegToAop (a, EXT(_gets_count_1_1), 0), stacked=0, isaddr=0
	sta	(_gets_count_1_1 + 1)
	bne	00122$
;     loadRegFromAop (a, EXT(_gets_count_1_1), 1)
	lda	_gets_count_1_1
	inca
;     storeRegToAop (a, EXT(_gets_count_1_1), 1), stacked=0, isaddr=0
	sta	_gets_count_1_1
00122$:
;gets.c:29: putchar(c);
;     genCall
;     loadRegFromAop (a, EXT(_gets_c_1_1), 0)
	lda	_gets_c_1_1
;     storeRegToAop (a, REG(-,-,-,a), 0), stacked=0, isaddr=0
; transferRegReg(a,a)
	jsr	_putchar
;gets.c:31: }
	jmp	00109$
00111$:
	rts
	.area CSEG (CODE)
	.area CONST   (CODE)
	.area XINIT
