Mercurial > repos > tabletprog
comparison modules/x86.tp @ 355:0b4d4f06bf91
Add support for setcc in x86 module. Add support for translating il skipIf:else and il bool instructions in x86 module.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 15 Apr 2015 21:14:44 -0700 |
parents | a3b06d53bcb9 |
children | f237d0cae58b |
comparison
equal
deleted
inserted
replaced
354:a6cdcc1b1c02 | 355:0b4d4f06bf91 |
---|---|
578 } | 578 } |
579 } else: { | 579 } else: { |
580 inst: 0xFFu8 | (mod_rm: (opex: 2u8) callDest) | 580 inst: 0xFFu8 | (mod_rm: (opex: 2u8) callDest) |
581 } | 581 } |
582 } | 582 } |
583 | |
584 setcc <- :cond dst { | |
585 src <- opex: 0u8 | |
586 base <- 0x0Fu8 | (0x90u8 or (cond cc)) | (mod_rm: (opex: 0u8) dst) | |
587 | |
588 inst: (prefix: fakesrc dst b withInstruction: base) | |
589 } | |
583 | 590 |
584 push <- :src { | 591 push <- :src { |
585 if: (src isInteger?) { | 592 if: (src isInteger?) { |
586 if: src < 128 && src > -128 { | 593 if: src < 128 && src > -128 { |
587 inst: 0x6Au8 | (uint8: src) | 594 inst: 0x6Au8 | (uint8: src) |
810 convertIL: inst to: outarr withLabels: labels withSaved: saved | 817 convertIL: inst to: outarr withLabels: labels withSaved: saved |
811 } | 818 } |
812 outarr append: endlab | 819 outarr append: endlab |
813 } | 820 } |
814 //skipIf:else | 821 //skipIf:else |
815 { } | 822 { |
823 endlab <- label: | |
824 elselab <- label: | |
825 outarr append: (jcc: (mapcond: (inst cond)) elselab) | |
826 foreach: (inst toskip) :_ inst { | |
827 convertIL: inst to: outarr withLabels: labels withSaved: saved | |
828 } | |
829 outarr append: (jmp: endlab) | |
830 outarr append: elselab | |
831 foreach: (inst else) :_ inst { | |
832 convertIL: inst to: outarr withLabels: labels withSaved: saved | |
833 } | |
834 outarr append: endlab | |
835 } | |
816 { | 836 { |
817 //save | 837 //save |
818 newsave <- [] | 838 newsave <- [] |
819 foreach: (inst tosave) :_ reg { | 839 foreach: (inst tosave) :_ reg { |
820 outarr append: (push: reg) | 840 outarr append: (push: reg) |
828 outarr append: (pop: reg) | 848 outarr append: (pop: reg) |
829 } | 849 } |
830 } | 850 } |
831 } | 851 } |
832 //bool | 852 //bool |
833 { } | 853 { |
854 outarr append: (setcc: (mapcond: (inst cond)) (inst out)) | |
855 } | |
834 ] | 856 ] |
835 print: "Opcode: " . (inst opcode) . "\n" | 857 print: "Opcode: " . (inst opcode) . "\n" |
836 fun <- opmap get: (inst opcode) | 858 fun <- opmap get: (inst opcode) |
837 fun: | 859 fun: |
838 outarr | 860 outarr |