Mathematische Routinen für AVR

Gast #90917
Lesenswert?

Division 24bit durch 16bit:
;bl, ah,al : ch, cl = bl, ah, al    REST in dh, dl
div24_16:
  ldi bh, 24
  clr dh
  mov dl, dh
loop24:
  lsl al
  rol ah
  rol bl
  rol dl
  rol dh
  cp dl, cl
  cpc  dh, ch
  brlo skip24
  sub dl, cl
  sbc dh, ch
  inc al
skip24:
  dec bh
  brne loop24
  ret
Gast #90918
Lesenswert?

Multiplikation 16bit mal 8bit:
mul16_8:
;multiplicate 16-bit number and 8-bit number
;ch,cl * dh = bl, ah, al
  clr ah
  clr al
  clr bl
  ldi bh, 8
loop16:
  clc
  rol al
  rol ah
  rol bl
  clc
  rol dh
  brcc not_plus
  add al, cl
  adc ah, ch
  brcc not_plus
  inc bl
not_plus:
  dec bh
  brne loop16
  ret

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren