Skip to content

Fix ADD X-flag: Add1() must use add_conditions() not sub_conditions() - #19

Merged
kg68k merged 1 commit into
kg68k:mainfrom
erique:dev
Feb 10, 2026
Merged

kg68k merged 1 commit into
kg68k:mainfrom
erique:dev

Conversation

@erique

@erique erique commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

I stumbled on this while running run68, and I believe there is a bug in add.l Dn,<ea>.

This small example highlights the issue:

; addx_flag.S
;
; Bug: Add1() uses sub_conditions() instead of add_conditions().
; Add1 handles "add Dn,<ea>" where <ea> is memory.
;
; Build: vasmm68k_mot -Fxfile -o addx_flag.x addx_flag.S
; Run:   run68 addx_flag.x

        section text,code

        move.l  #$FFFFFFFF,-(sp)
        move.l  #1,d0
        add.l   d0,(sp)         ; $FFFFFFFF+1=$00000000, carry -> X=1
        clr.l   d0
        addx.l  d0,d0           ; d0 = 0+0+X = 1 if correct, 0 if bug
        add.b   #'0',d0         ; '1' if correct, '0' if bug
        move.w  d0,-(sp)
        dc.w    $FF02           ; _DOS_PUTCHAR
        addq.l  #4,sp           ; clean PUTCHAR + test value

        pea     crlf
        dc.w    $FF09           ; _DOS_PRINT
        addq.l  #4,sp

        clr.w   -(sp)
        dc.w    $FF4C           ; _DOS_EXIT2(0)

crlf:   dc.b    $0d,$0a,0

(I use vasm due to my background on the Amiga, but I guess HAS would build the code just fine..)

It should print 1 (the X/carry flag).

@kg68k kg68k added the bug Something isn't working label Feb 10, 2026
@kg68k kg68k self-assigned this Feb 10, 2026
@kg68k
kg68k merged commit ee35cbd into kg68k:main Feb 10, 2026
6 checks passed
@kg68k

kg68k commented Feb 10, 2026

Copy link
Copy Markdown
Owner

thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants