Skip to content
This repository was archived by the owner on Dec 23, 2025. It is now read-only.
This repository was archived by the owner on Dec 23, 2025. It is now read-only.

6502: division with promotion error #220

@kwhr0

Description

@kwhr0
int func(void) {
        int a = 0x0a0b;
        char b = 0x0c;
        return a / b;
}
_func:
;invalidate regs
        ldy #3
        jsr __subysp
        ldx #10
        lda #11
        pha
        ldy #0
        sta (@sp),y
        txa
        iny
        sta (@sp),y
        pla
;:
        lda #12
        iny
        sta (@sp),y
;:
        dey
        lda (@sp),y
        tax
        dey
        lda (@sp),y
        ldx #0        <---
        sta @tmp
        stx @tmp+1
        ldy #2
        lda (@sp),y
;invalidate regs
        jsr __divtmp
;:
        jmp L0_r
L0_r:
;invalidate regs
        ldy #3
        jmp __addysp

ldx #0 should be after stx @tmp+1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions