home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / EXTRA-ST / CPM-80-E / CPM-0.2 / CPM-0 / cpm-0.2 / code2.s < prev    next >
Encoding:
Text File  |  1994-06-15  |  9.6 KB  |  351 lines

  1. /*****************************************************************************/
  2. /*                                         */
  3. /*                                         */
  4. /*    CP/M emulator version 0.1                         */
  5. /*                                         */
  6. /*    written by Michael Bischoff (mbi@mo.math.nat.tu-bs.de)             */
  7. /*    June-1994                                 */
  8. /*                                         */
  9. /*    This file is distributed under the GNU COPYRIGHT             */
  10. /*    see COPYRIGHT.GNU for Copyright details                     */
  11. /*                                         */
  12. /*                                         */
  13. /*****************************************************************************/
  14.          /* Opcodes ED xx ohne Flagbeeinflussung */
  15.  
  16.         .data
  17. jumptab2:    .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  18.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  19.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  20.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  21.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  22.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  23.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  24.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  25.  
  26.         .long EXIT2, EXIT2, ed42,  ed43,  ed44,  EXIT2, EXIT2, ed47
  27.         .long EXIT2, EXIT2, ed4a,  ed4b,  EXIT2, opc9,  EXIT2, ed4f
  28.         .long EXIT2, EXIT2, ed52,  ed53,  EXIT2, EXIT2, EXIT2, ed57
  29.         .long EXIT2, EXIT2, ed5a,  ed5b,  EXIT2, EXIT2, EXIT2, ed5f
  30.         .long EXIT2, EXIT2, ed62,  ed63,  EXIT2, EXIT2, EXIT2, ed67
  31.         .long EXIT2, EXIT2, ed6a,  ed6b,  EXIT2, EXIT2, EXIT2, ed6f
  32.         .long EXIT2, EXIT2, ed72,  ed73,  EXIT2, EXIT2, EXIT2, EXIT2
  33.         .long EXIT2, EXIT2, ed7a,  ed7b,  EXIT2, EXIT2, EXIT2, EXIT2
  34.  
  35.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  36.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  37.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  38.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  39.         .long eda0,  eda1,  EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  40.         .long eda8,  eda9,  EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  41.         .long edb0,  edb1,  EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  42.         .long edb8,  edb9,  EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  43.  
  44.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  45.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  46.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  47.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  48.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  49.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  50.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  51.         .long EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2, EXIT2
  52.  
  53. #define edcode(n) .align NALIGN,0x90
  54.  
  55.                 edcode (0x42)        /* SBC HL,BC */
  56. ed42:           orb $2,%ah
  57.                 sahf
  58.                 sbbw %cx,%bx
  59.                 jmp setaddadc
  60.  
  61.                 edcode (0x43)        /* LD (nnnn),BC */
  62. ed43:           movzwl (%esi,%ebp),%edi
  63.                 incl %esi
  64.                 incl %esi
  65.                 movw %cx,(%ebp,%edi)
  66.                 dispatch
  67.  
  68.                 edcode (0x4a)        /* ADC HL,BC */
  69. ed4a:           andb $0xd5,%ah
  70.                 sahf
  71.                 adcw %cx,%bx
  72.                 jmp setaddadc
  73.  
  74.                 edcode (0x4b)        /* LD BC,(nnnn) */
  75. ed4b:        movzwl (%esi,%ebp),%edi
  76.                 incl %esi
  77.                 incl %esi
  78.                 movw (%ebp,%edi),%cx
  79.                 dispatch
  80.  
  81.                 edcode (0x52)        /* SBC HL,DE */
  82. ed52:           orb $2,%ah
  83.                 sahf
  84.                 sbbw %dx,%bx
  85.                 jmp setaddadc
  86.  
  87.                 edcode (0x53)        /* LD (nnnn),DE */
  88. ed53:           movzwl (%esi,%ebp),%edi
  89.                 incl %esi
  90.                 incl %esi
  91.                 movw %dx,(%ebp,%edi)
  92.                 dispatch
  93.  
  94.                 edcode (0x5a)        /* ADC HL,DE */
  95. ed5a:           andb $0xd5,%ah
  96.                 sahf
  97.                 adcw %dx,%bx
  98.                 jmp setaddadc
  99.  
  100.                 edcode (0x5b)        /* LD DE,(nnnn) */
  101. ed5b:        movzwl (%esi,%ebp),%edi
  102.                 incl %esi
  103.                 incl %esi
  104.                 movw (%ebp,%edi),%dx
  105.                 dispatch
  106.  
  107.                 edcode (0x62)        /* SBC HL,HL */
  108. ed62:           orb $2,%ah
  109.                 sahf
  110.                 sbbw %bx,%bx
  111.                 jmp setaddadc
  112.  
  113.                 edcode (0x63)        /* LD (nnnn),HL */
  114. ed63:           movzwl (%esi,%ebp),%edi
  115.                 incl %esi
  116.                 incl %esi
  117.                 movw %bx,(%ebp,%edi)
  118.                 dispatch
  119.  
  120.                 edcode (0x6a)        /* ADC HL,HL */
  121. ed6a:           andb $0xd5,%ah
  122.                 sahf
  123.                 adcw %bx,%bx
  124.                 jmp setaddadc
  125.  
  126.                 edcode (0x6b)        /* LD HL,(nnnn) */
  127. ed6b:        movzwl (%esi,%ebp),%edi
  128.                 incl %esi
  129.                 incl %esi
  130.                 movw (%ebp,%edi),%bx
  131.                 dispatch
  132.  
  133.                 edcode (0x72)        /* SBC HL,SP */
  134. ed72:           orb $2,%ah
  135.                 sahf
  136.                 sbbw _z80regs+4,%bx
  137.                 jmp setaddadc
  138.  
  139.                 edcode (0x73)        /* LD (nnnn),SP */
  140. ed73:           movzwl (%esi,%ebp),%edi
  141.                 incl %esi
  142.                 incl %esi
  143.         pushl %eax
  144.         movw _z80regs+4,%ax
  145.                 movw %ax,(%ebp,%edi)
  146.         popl %eax
  147.                 dispatch
  148.  
  149.                 edcode (0x7a)        /* ADC HL,SP */
  150. ed7a:           andb $0xd5,%ah
  151.                 sahf
  152.                 adcw _z80regs+4,%bx
  153.                 jmp setaddadc
  154.  
  155.                 edcode (0x7b)        /* LD SP,(nnnn) */
  156. ed7b:        movzwl (%esi,%ebp),%edi
  157.                 incl %esi
  158.                 incl %esi
  159.                 movw (%ebp,%edi),%di
  160.         movw %di,_z80regs+4
  161.                 dispatch
  162.  
  163.  
  164.                 edcode (0x44)        /* NEG */
  165. ed44:           orb $2,%ah
  166.                 negb %al
  167.         movl %eax,%edi
  168.                 lahf
  169.                 seto %al
  170.                 shlb $2,%al
  171.                 andb $0xd1,%ah
  172.                 orb %al,%ah
  173.                 andl $0x2ff,%edi
  174.                 xorb %al,%al
  175.                 orl %edi,%eax
  176.                 dispatch
  177.  
  178.             edcode (0x47)        /* LD I,A */
  179. ed47:           movb %al,_z80regs+25
  180.                 dispatch
  181.             edcode (0x4f)        /* LD R,A */
  182. ed4f:           movb %al,_z80regs+24
  183.                 dispatch
  184.             edcode (0x57)        /* LD A,I */
  185. ed57:           movb _z80regs+25,%al
  186.                 dispatch
  187.             edcode (0x5f)        /* LD A,R */
  188. ed5f:           movb _z80regs+24,%al
  189.                 andb $0x7f,%al        /* is NOT random */
  190.                 dispatch
  191.  
  192.  
  193.  
  194.                 edcode (0xa0)        /* LDI */
  195. eda0:           pushl %eax
  196.                 movb (%ebp,%ebx),%al
  197.                 movb %al,(%ebp,%edx)
  198.                 incw %bx
  199.                 incw %dx
  200.                 decw %cx
  201.                 setnz %al
  202.                 shlb $2,%al
  203.                 andb $0xe9,%ah
  204.                 orb %al,%ah
  205.                 xorb %al,%al
  206.                 xchgl %eax,%edi
  207.                 popl %eax
  208.                 xorb %ah,%ah
  209.                 orl %edi,%eax
  210.                 dispatch
  211.  
  212.                 edcode (0xa8)        /* LDD */
  213. eda8:           pushl %eax
  214.                 movb (%ebp,%ebx),%al
  215.                 movb %al,(%ebp,%edx)
  216.                 decw %bx
  217.                 decw %dx
  218.                 decw %cx
  219.                 setnz %al
  220.                 shlb $2,%al
  221.                 andb $0xe9,%ah
  222.                 orb %al,%ah
  223.                 xorb %al,%al
  224.                 xchgl %eax,%edi
  225.                 popl %eax
  226.                 xorb %ah,%ah
  227.                 orl %edi,%eax
  228.                 dispatch
  229.  
  230.                 edcode (0xb0)        /* LDIR */
  231. edb0:           cld
  232.                 jmp do_ldir
  233.  
  234.                 edcode (0xb8)           /* LDDR */
  235. edb8:           std
  236. do_ldir:        pushl %edi
  237.                 pushl %esi
  238.                 movl %ebx,%esi
  239.                 movl %edx,%edi
  240.         addl %ebp,%esi
  241.         addl %ebp,%edi
  242.                 rep
  243.         movsb
  244.         subl %ebp,%esi
  245.         subl %ebp,%edi
  246.                 movl %esi,%ebx
  247.                 movl %edi,%edx
  248.                 popl %esi
  249.                 popl %edi
  250.                 andb $0xe9,%ah
  251.                 cld
  252.                 dispatch
  253.  
  254.  
  255.                 edcode (0xb1)    /* CPIR */
  256. edb1:           movl %eax,%edi
  257.         andw $0xbbff,%di
  258. cpirloop:
  259.                 cmpb (%ebp,%ebx),%al
  260.         jz cpir1
  261.                 incw %bx
  262.                 decw %cx
  263.         jnz cpirloop
  264.         movb $0x06,%ah
  265.         orw %di,%ax
  266.         dispatch
  267.         .align 2,0x90
  268. cpir1:        incw %bx
  269. cpirdr:         decw %cx
  270.                 setnz %ah
  271.                 shlb $2,%ah
  272.         orb $0x42,%ah
  273.         orw %di,%ax
  274.         dispatch
  275.  
  276.                 edcode (0xb9)    /* CPDR */
  277. edb9:           movl %eax,%edi
  278.         andw $0xbbff,%di
  279. cpdrloop:
  280.                 cmpb (%ebp,%ebx),%al
  281.         jz cpdr1
  282.                 decw %bx
  283.                 decw %cx
  284.         jnz cpdrloop
  285.         movb $0x06,%ah
  286.         orw %di,%ax
  287.         dispatch
  288.         .align 2,0x90
  289. cpdr1:        decw %bx
  290.         jmp cpirdr
  291.  
  292.  
  293.  
  294.                 edcode (0xa1)    /* CPI */
  295. eda1:           movl %eax,%edi
  296.         andw $0x29ff,%di
  297.                 cmpb (%ebp,%ebx),%al
  298.         lahf
  299.         andb $0xd0,%ah
  300.                 incw %bx
  301.                 decw %cx
  302.                 setnz %al
  303.                 shlb $2,%al
  304.         orb $0x02,%al
  305.         orb %al,%ah
  306.         xorb %al,%al
  307.         orw %di,%ax
  308.         dispatch
  309.  
  310.                 edcode (0xa9)    /* CPD */
  311. eda9:           movl %eax,%edi
  312.         andw $0x29ff,%di
  313.                 cmpb (%ebp,%ebx),%al
  314.         lahf
  315.         andb $0xd0,%ah
  316.                 decw %bx
  317.                 decw %cx
  318.                 setnz %al
  319.                 shlb $2,%al
  320.         orb $0x02,%al
  321.         orb %al,%ah
  322.         xorb %al,%al
  323.         orw %di,%ax
  324.         dispatch
  325.  
  326.  
  327.                 edcode (0x67)    /* RRD */
  328. ed67:           movl %eax,%edi
  329.                 movb (%ebp,%ebx),%ah
  330.         rorw $4,%ax
  331.         rorb $4,%al
  332.                 movb %ah,(%ebp,%ebx)
  333.         orb %al,%al
  334.         lahf
  335.         andb $0xc4,%ah
  336.         andl $0x28ff,%edi
  337.         orw %edi,%eax
  338.         dispatch
  339.  
  340.                 edcode (0x6f)    /* RLD */
  341. ed6f:           movl %eax,%edi
  342.                 movb (%ebp,%ebx),%ah
  343.         rolb $4,%al
  344.         rolw $4,%ax
  345.                 movb %ah,(%ebp,%ebx)
  346.         orb %al,%al
  347.         lahf
  348.         andb $0xc4,%ah
  349.         andl $0x28ff,%edi
  350.         orw %edi,%eax
  351.         dispatch