; ; File generated by cc65 v 2.11.0 ; .fopt compiler,"cc65 v 2.11.0" .setcpu "6502" .smart on .autoimport on .case on .debuginfo on .importzp sp, sreg, regsave, regbank, tmp1, ptr1, ptr2 .macpack longbranch .dbg file, "gets.c", 897, 1068141847 .dbg file, "../../include/stdio.h", 5945, 1113916546 .dbg file, "../../include/stddef.h", 2974, 1061022172 .dbg file, "../../include/stdarg.h", 2817, 1102777145 .dbg file, "./_file.h", 742, 1084367783 .import _stdin .import _fgetc .export _gets ; --------------------------------------------------------------- ; unsigned char* __fastcall__ gets (unsigned char*) ; --------------------------------------------------------------- .segment "CODE" .proc _gets .segment "CODE" ; ; { ; .dbg line, "gets.c", 21 jsr pushax ; ; int i = 0; ; .dbg line, "gets.c", 23 jsr decsp2 ldx #$00 txa jsr pushax ; ; if ((c = fgetc (stdin)) == EOF) { ; .dbg line, "gets.c", 28 L0005: lda _stdin ldx _stdin+1 jsr _fgetc ldy #$02 jsr staxysp cpx #$FF bne L0018 cmp #$FF bne L0018 ; ; s [i] = 0; ; .dbg line, "gets.c", 30 ldy #$04 lda (sp),y clc ldy #$00 adc (sp),y pha ldy #$05 lda (sp),y ldy #$01 adc (sp),y tax pla sta sreg stx sreg+1 lda #$00 dey sta (sreg),y ; ; if (stdin->f_flags & _FERROR) { ; .dbg line, "gets.c", 31 lda _stdin ldx _stdin+1 iny sta ptr1 stx ptr1+1 lda (ptr1),y and #$04 beq L0011 ; ; return 0; ; .dbg line, "gets.c", 33 ldx #$00 txa jmp incsp6 ; ; if (i) { ; .dbg line, "gets.c", 36 L0011: lda (sp),y dey ora (sp),y ; ; return s; ; .dbg line, "gets.c", 37 bne L0026 ; ; return 0; ; .dbg line, "gets.c", 39 tax jmp incsp6 ; ; s [i++] = c; ; .dbg line, "gets.c", 45 L0018: ldy #$07 jsr pushwysp ldy #$03 jsr ldaxysp sta regsave stx regsave+1 clc adc #$01 bcc L001C inx L001C: ldy #$02 jsr staxysp lda regsave ldx regsave+1 jsr tosaddax sta sreg stx sreg+1 ldy #$02 lda (sp),y ldy #$00 sta (sreg),y ; ; } while (c != '\n'); ; .dbg line, "gets.c", 47 ldy #$03 lda (sp),y jne L0005 dey lda (sp),y cmp #$0D jne L0005 ; ; s [i-1] = '\0'; ; .dbg line, "gets.c", 50 ldy #$05 jsr ldaxysp sta sreg stx sreg+1 ldy #$01 jsr ldaxysp sec sbc #$01 bcs L0022 dex L0022: clc adc sreg sta sreg txa adc sreg+1 tax lda sreg sta sreg stx sreg+1 lda #$00 tay sta (sreg),y ; ; return s; ; .dbg line, "gets.c", 53 L0026: ldy #$05 jsr ldaxysp ; ; } ; .dbg line, "gets.c", 54 jmp incsp6 .dbg line .endproc