; ; 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 _stderr .import _fputc .import _fputs .import _strchr .export _optarg .export _optind .export _opterr .export _optopt .export _getopt .segment "DATA" _opterr: .word $0001 _optind: .word $0001 .segment "RODATA" S0004: .byte $3A,$20,$6F,$70,$74,$69,$6F,$6E,$20,$72,$65,$71,$75,$69,$72,$65 .byte $73,$20,$61,$6E,$20,$61,$72,$67,$75,$6D,$65,$6E,$74,$20,$2D,$2D .byte $20,$00 S0002: .byte $3A,$20,$69,$6C,$6C,$65,$67,$61,$6C,$20,$6F,$70,$74,$69,$6F,$6E .byte $20,$2D,$2D,$20,$00 S0003 := S0004+33 S0005 := S0004+33 S0001 := S0004+33 .segment "BSS" _optarg: .res 2,$00 _optopt: .res 2,$00 ; --------------------------------------------------------------- ; int __near__ __fastcall__ getopt (int argc, char * const *argv, const char *optstring) ; --------------------------------------------------------------- .segment "CODE" .proc _getopt: near .segment "CODE" jsr pushax lda regbank+4 ldx regbank+5 jsr pushax lda M0001+1 sta ptr1+1 lda M0001 sta ptr1 ldy #$00 lda (ptr1),y bne L0007 lda _optind ldy #$06 cmp (sp),y lda _optind+1 iny sbc (sp),y bvs L001B eor #$80 L001B: bmi L001E lda _optind ldx _optind+1 jsr aslax1 clc ldy #$04 adc (sp),y pha txa iny adc (sp),y tax pla jsr ldaxi sta M0001 stx M0001+1 sta ptr1 stx ptr1+1 ldy #$00 lda (ptr1),y cmp #$2D bne L001E inc M0001 bne L0005 inc M0001+1 L0005: lda M0001+1 sta ptr1+1 lda M0001 sta ptr1 lda (ptr1),y bne L0003 L001E: ldx #$FF txa jmp L0001 L0003: lda M0001+1 sta ptr1+1 lda M0001 sta ptr1 lda (ptr1),y cmp #$2D bne L0007 inc _optind bne L0008 inc _optind+1 L0008: ldx #$FF txa jmp L0001 L0007: lda M0001+1 sta ptr1+1 lda M0001 sta ptr1 ldx #$00 lda (ptr1),y sta _optopt stx _optopt+1 cmp #$3A jsr booleq php inc M0001 bne L000B inc M0001+1 L000B: plp bne L001F ldy #$05 jsr pushwysp lda _optopt ldx _optopt+1 jsr _strchr sta regbank+4 stx regbank+4+1 jsr bnegax beq L0009 L001F: lda M0001+1 sta ptr1+1 lda M0001 sta ptr1 lda (ptr1,x) bne L000E inc _optind bne L000E inc _optind+1 L000E: ldy #$05 jsr ldaxysp jsr pushw lda _stderr ldx _stderr+1 jsr _fputs lda #<(S0002) ldx #>(S0002) jsr pushax lda _stderr ldx _stderr+1 jsr _fputs lda _optopt ldx _optopt+1 jsr pushax lda _stderr ldx _stderr+1 jsr _fputc lda #$0A jsr pusha0 lda _stderr ldx _stderr+1 jsr _fputc ldx #$00 lda #$3F jmp L0001 L0009: inc regbank+4 bne L0011 inc regbank+4+1 L0011: lda (regbank+4,x) cmp #$3A beq L0010 txa sta _optarg sta _optarg+1 lda M0001+1 sta ptr1+1 lda M0001 sta ptr1 lda (ptr1,x) jne L0014 jmp L0022 L0010: lda M0001+1 sta ptr1+1 lda M0001 sta ptr1 lda (ptr1,x) beq L0015 lda M0001+1 sta _optarg+1 lda M0001 sta _optarg jmp L0019 L0015: ldy #$09 jsr pushwysp inc _optind bne L0018 inc _optind+1 L0018: lda _optind ldx _optind+1 jsr tosicmp beq L001D bpl L0017 L001D: lda #>(S0003) sta M0001+1 lda #<(S0003) sta M0001 ldy #$05 jsr ldaxysp jsr pushw lda _stderr ldx _stderr+1 jsr _fputs lda #<(S0004) ldx #>(S0004) jsr pushax lda _stderr ldx _stderr+1 jsr _fputs lda _optopt ldx _optopt+1 jsr pushax lda _stderr ldx _stderr+1 jsr _fputc lda #$0A jsr pusha0 lda _stderr ldx _stderr+1 jsr _fputc ldx #$00 lda #$3F jmp L0001 L0017: lda _optind ldx _optind+1 jsr aslax1 clc ldy #$04 adc (sp),y pha txa iny adc (sp),y tax pla jsr ldaxi sta _optarg stx _optarg+1 L0019: lda #>(S0005) sta M0001+1 lda #<(S0005) sta M0001 L0022: inc _optind bne L0014 inc _optind+1 L0014: lda _optopt ldx _optopt+1 L0001: pha ldy #$00 lda (sp),y sta regbank+4 iny lda (sp),y sta regbank+5 pla jmp incsp8 .segment "DATA" M0001: .addr S0001 .endproc