Working on a programming exercise... and having a brain fart of sorts. Could someone please help me correct this division syntax?
Thanks!!
>>>>>>
Divi cjbe Input2Hi,#0,Zerocheck
Zerocheck cjbe Input2Lo,#0,ZeroDiv
clr quotient ;initializes quotient to zero
Divloop cjbe Input1Hi,Input2Hi,donedivhi ;checks if highbit of dividend LT or = to highbit of divisor
mov DiffLo,Input1Lo
mov DiffHi,Input1Hi
clc
sub DiffLo,Input2Lo
jc DecHi2 ;if no carry occurs in previous subtraction, must decrement high bit to account for a borrow
dec DiffHi ;decrement highbit
DecHi2 Sub DiffHi,Input2Hi
mov Input1Lo,DiffLo
mov Input1Hi,DiffHi
inc quotient
jmp Divloop
donedivhi
divlooplo cjb Input1lo,Input2lo,Donediv
mov DiffLo,Input1Lo
clc
sub DiffLo,Input2Lo ;subtracts second low num from DiffLo
mov Input1Lo,DiffLo
inc quotient
jmp divlooplo
Donediv mov X,quotient
call Output
mov remainder,Input1Lo
mov X,remainder
call Output
mov remainder,DiffHi
mov X,remainder
call Output
jmp Mainloop
ZeroDiv mov rb,#$00000000
call delay
mov rb,#$ff
call delay
mov rb,#$00000000
call delay
mov rb,#$ff
call delay
mov rb,#$00000000
call delay
mov rb,#$ff
call delay
mov rb,#$00000000
call delay
mov rb,#$ff
jmp Mainloop
Thanks!!
>>>>>>
Divi cjbe Input2Hi,#0,Zerocheck
Zerocheck cjbe Input2Lo,#0,ZeroDiv
clr quotient ;initializes quotient to zero
Divloop cjbe Input1Hi,Input2Hi,donedivhi ;checks if highbit of dividend LT or = to highbit of divisor
mov DiffLo,Input1Lo
mov DiffHi,Input1Hi
clc
sub DiffLo,Input2Lo
jc DecHi2 ;if no carry occurs in previous subtraction, must decrement high bit to account for a borrow
dec DiffHi ;decrement highbit
DecHi2 Sub DiffHi,Input2Hi
mov Input1Lo,DiffLo
mov Input1Hi,DiffHi
inc quotient
jmp Divloop
donedivhi
divlooplo cjb Input1lo,Input2lo,Donediv
mov DiffLo,Input1Lo
clc
sub DiffLo,Input2Lo ;subtracts second low num from DiffLo
mov Input1Lo,DiffLo
inc quotient
jmp divlooplo
Donediv mov X,quotient
call Output
mov remainder,Input1Lo
mov X,remainder
call Output
mov remainder,DiffHi
mov X,remainder
call Output
jmp Mainloop
ZeroDiv mov rb,#$00000000
call delay
mov rb,#$ff
call delay
mov rb,#$00000000
call delay
mov rb,#$ff
call delay
mov rb,#$00000000
call delay
mov rb,#$ff
call delay
mov rb,#$00000000
call delay
mov rb,#$ff
jmp Mainloop