?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. #ifndef included_mul24
  2. #define included_mul24
  3. #include "C_Times_BDE.z80"
  4. mul24:
  5. ;BDE*CHL ->  BHLDEA
  6. ;510+{0,39}+{0,8}+3*C_Times_BDE
  7. ;61 bytes
  8.     push hl
  9.     pop ix
  10.     call C_Times_BDE  ; CAHL
  11.     push hl
  12.     ld l,a
  13.     ld h,c
  14.     ex (sp),hl
  15.     push hl
  16.  
  17.     ld a,b
  18.     push ix
  19.     pop bc
  20.     ld b,a
  21.     call C_Times_BDE  ; CAHL
  22.     ;CA + stack without destroying BDE
  23.     ex (sp),hl
  24.     add a,l
  25.     ld l,a
  26.     ld a,c
  27.     adc a,h
  28.     ld h,a
  29.  ;   {1}HL{2}
  30.     ld a,b
  31.     push ix
  32.     pop bc
  33.     ld c,b
  34.     ld b,a
  35.     pop ix
  36.   ;  IXHL{1}
  37.     jr nc,+_
  38.     ex (sp),hl
  39.     inc hl
  40.     ex (sp),hl
  41. _:
  42.     push hl
  43.     push ix
  44. ;    {3}{2}{1}
  45.  
  46.     call C_Times_BDE
  47.     dec sp
  48.     ;CAHL
  49.     pop de    ;D is the bottom byte
  50.     ld b,d    ;B is the bottom byte
  51.     pop de
  52.     add hl,de ;HL is bytes 1 and 2
  53.     ld d,c
  54.     ld e,a
  55.     ex (sp),hl
  56.     adc hl,de ;HL is bytes 3 and 4
  57.     pop de    ;DE is bytes 1 and 2
  58.     ld a,b    ;A is the bottom byte
  59.     dec sp
  60.     pop bc    ;B is the top byte
  61.     ret nc
  62.     inc b
  63. ;    BHLDEA
  64.     ret
  65. #endif
  66.