home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / b / krtnhd.mac < prev    next >
Text File  |  2020-01-01  |  2KB  |  85 lines

  1.     .sbttl    KRTNHD    EIS macros for a non-EIS CPU
  2.     .ident    "V03.63"
  3.  
  4. ; /63/    27-Sep-97  Billy Youdelman  V03.63
  5. ; /62/    27-Jul-93  Billy Youdelman  V03.62
  6. ; /BBS/     1-Dec-91  Billy Youdelman  V03.61
  7. ;
  8. ;    Assemble Kermit-11 modules with this for use on a
  9. ;    non-EIS CPU.  This calls p$mul and p$div, assembly
  10. ;    of which into KRTSUB depends on defining "NONEIS".
  11. ;    KRTASM.NON assembles everything for non-EIS use.
  12.  
  13. ;    10-Apr-84  09:37:15  Brian Nelson
  14.  
  15.     NONEIS    =    1        ; force p$mul,p$div into KRTSUB.MAC
  16.  
  17.     .macro    mul    src,reg        ; single precision
  18.     .ntype    $$    ,reg        ; save number of input register
  19.     mov    src    ,-(sp)        ; pass multiplier to p$mul
  20.     mov    reg    ,-(sp)        ; pass multiplicand too
  21.     call    p$mul            ; multiply, returns a 16-bit product
  22.     .iif eq <$$-1>    mov    (sp)+    ,r1    ; ..if input register was r1
  23.     .iif eq <$$-3>    mov    (sp)+    ,r3    ; ditto if r3
  24.     .iif eq <$$-5>    mov    (sp)+    ,r5    ; ditto if r5
  25.     .iif ne <<$$+1>&1> .error      <; bad dst reg for MUL macro>
  26.     .endm    mul
  27.  
  28.     .macro    div    src,reg        ; /BBS/ made this double precision
  29.     .ntype    $$    ,reg        ; # of register with dividend hi word
  30.     mov    src    ,-(sp)        ; divisor
  31.     .if eq $$            ; hi word is in r0
  32.     mov    r1    ,-(sp)        ; dividend low word
  33.     mov    r0    ,-(sp)        ; dividend high word
  34.     .endc
  35.     .if eq $$-2            ; hi word is in r2
  36.     mov    r3    ,-(sp)
  37.     mov    r2    ,-(sp)
  38.     .endc
  39.     .if eq $$-4            ; hi word is in r4
  40.     mov    r5    ,-(sp)
  41.     mov    r4    ,-(sp)
  42.     .endc
  43.     call    p$div            ; divide
  44.     .if eq $$            ; using r0..
  45.     mov    (sp)+    ,r1        ; remainder
  46.     mov    (sp)+    ,r0        ; this only returns a 16-bit quotient
  47.     .endc
  48.     .if eq $$-2            ; using r2..
  49.     mov    (sp)+    ,r3
  50.     mov    (sp)+    ,r2
  51.     .endc
  52.     .if eq $$-4            ; using r4..
  53.     mov    (sp)+    ,r5
  54.     mov    (sp)+    ,r4
  55.     .endc
  56.     .endm    div
  57.  
  58.     .macro    sob    reg,dst        ; subtract one and branch if not zero
  59.     dec    reg
  60.     bne    dst
  61.     .endm    sob
  62.  
  63.     .macro    ash    amount,reg    ; arithmetic shift
  64.     .ntype    $$$0    ,amount
  65.     .iif ne <27-$$$0> .error       <; must be auto pc for ASH macro>
  66.     $$type    = 1            ; assume left shift
  67.     $$size    = 0            ; how many ASLs or ASRs to generate
  68.       .irpc    $a ,<amount>        ; parse the first argument
  69.       $c    = ''$a            ; get the character as a literal
  70.       .iif eq <$c - '-> $$type = -1    ; if a minus sign then assume right
  71.       .iif eq <$c - '.> .error     <; only use octal in ASH macro please>
  72.       .iif eq <$c - '^> .error     <; only use octal in ASH macro please>
  73.       $c    = $c - '0        ; check for a digit now
  74.         .if ge $c            ; perhaps a digit
  75.           .if le $c-7        ; got a digit
  76.           $$size = <$$size*10>+$c    ; add into accumulator
  77.           .endc
  78.         .endc
  79.       .endr
  80.     .rept    $$size
  81.     .iif gt <$$type>  asl    reg
  82.     .iif lt <$$type>  asr    reg
  83.     .endr
  84.     .endm
  85.