; ; File generated by cc65 v 2.19 - Git ab8bb268 ; .fopt compiler,"cc65 v 2.19 - Git ab8bb268" .setcpu "6502" .smart on .autoimport on .case on .debuginfo off .importzp sp, sreg, regsave, regbank .importzp tmp1, tmp2, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4 .macpack longbranch .import _fgetc .export _fgets .import __seterrno ; --------------------------------------------------------------- ; char *__near__ __fastcall__ fgets (char *s, unsigned int size, register struct _FILE *f) ; --------------------------------------------------------------- .segment "CODE" .proc _fgets: near .segment "CODE" jsr pushax ldy #$00 ldx #$04 jsr regswap2 lda regbank+2 ldx regbank+3 jsr pushax ldy #$07 jsr ldaxysp sta regbank+2 stx regbank+2+1 jsr decsp4 ldy #$08 lda (sp),y iny ora (sp),y bne L0002 lda #$07 jsr __seterrno jmp L0001 L0002: ldx #$00 txa ldy #$02 jsr staxysp jmp L0013 L0004: lda regbank+4 ldx regbank+4+1 jsr _fgetc jsr stax0sp cpx #$FF bne L000E cmp #$FF bne L000E ldy #$01 lda (regbank+4),y and #$04 bne L0012 iny lda (sp),y iny ora (sp),y bne L0005 L0012: lda #$00 tay sta (regbank+2),y inx jmp L0001 L000E: ldy #$00 lda (sp),y sta (regbank+2),y inc regbank+2 bne L000F inc regbank+2+1 L000F: ldy #$02 ldx #$00 lda #$01 jsr addeqysp ldy #$00 lda (sp),y cmp #$0A beq L0005 ldx #$00 L0013: lda #$01 ldy #$08 jsr subeqysp stx tmp1 ora tmp1 bne L0004 L0005: lda #$00 tay sta (regbank+2),y ldy #$0B jsr ldaxysp L0001: pha stx tmp1 ldy #$07 ldx #$03 L0011: lda (sp),y sta regbank+2,x dey dex bpl L0011 ldx tmp1 pla ldy #$0C jmp addysp .endproc