;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- ;; Note that the compile dont understand if its out of mem. ;; Please run without linking other stuff. thats also why some code is commented out. ;; Add it back in for debugging! .scope div_test A_temp = $4043 .include "arithmatic.inc" .repeat $17, i .repeat $17, j ;INC $400D ;; print number of iterations on screen. LDX #i STX VAL_A STX A_temp LDY #j STY VAL_B JSR div ; A = VAL_A / VAL_B, clobers X. .if j <> 0 ;; This is undefined, should not get stuck in loop, dont care about result! CMP #i/j BEQ :+ jmp error : .endif .endrepeat .endrepeat no_error: ;; All good make screen green. ;; If not red or green, then we have infinate loop in mult. LDX #$05 STX $D020 jmp end error: ;; Error make screen read ;; X * Y has the result in A that is wrong. LDX #$02 STX $D020 end: LDX A_temp ; X = VAL_A ; Y = VAL_B ; A = awnser. .endscope