initial commit: a mess of assembly code
[fmap.git] / x86_64_sse2_x87 / fasm / examples / x86 / include / 80286.inc
blobf9e8ee4bee405618e5abafd2b1c51efbb45e871b
1 \r
2 include '80186.inc'\r
3 \r
4 iterate <instr,opcode>, loadall,<0Fh,05h>, clts,<0Fh,06h>\r
5 \r
6         define x86.instr? db opcode\r
7 \r
8         calminstruction instr?\r
9                 assemble x86.instr?\r
10         end calminstruction\r
12 end iterate\r
14 calminstruction arpl? dest*,src*\r
15         asmcmd  =x86.=parse_operand =@dest,dest\r
16         asmcmd  =x86.=parse_operand =@src,src\r
17         check   @src.type = 'reg' & (@dest.type = 'mem' | @dest.type = 'reg')\r
18         jno     invalid_combination_of_operands\r
19         check   @src.size = 2\r
20         jno     invalid_operand_size\r
21         check   @dest.size and not @src.size\r
22         jno     size_ok\r
23         asmcmd  =err 'operand sizes do not match'\r
24         jump    size_ok\r
25     invalid_operand_size:\r
26         asmcmd  =err 'invalid operand size'\r
27     size_ok:\r
28         asmcmd  =x86.=store_instruction 63h,=@dest,=@src.=rm\r
29         exit\r
30     invalid_combination_of_operands:\r
31         asmcmd  =err 'invalid combination of operands'\r
32 end calminstruction\r
34 iterate <instr,ext,postbyte>, sldt,0,0, str,0,1, lldt,0,2, ltr,0,3, verr,0,4, verw,0,5, smsw,1,4, lmsw,1,6\r
36         calminstruction instr? dest*\r
37                 asmcmd  =x86.=parse_operand =@dest,dest\r
38                 check   @dest.size and not 2\r
39                 jno     size_ok\r
40                 asmcmd  =err 'invalid operand size'\r
41             size_ok:\r
42                 check   @dest.type = 'reg' | @dest.type = 'mem'\r
43                 jyes    operand_ok\r
44                 asmcmd  =err 'invalid operand'\r
45                 exit\r
46             operand_ok:\r
47                 asmcmd  =x86.=store_instruction <0Fh,ext>,=@dest,postbyte\r
48         end calminstruction\r
50 end iterate\r
52 iterate <instr,postbyte>, lgdt,2, lidt,3, sgdt,0, sidt,1\r
54         calminstruction instr? dest*\r
55                 asmcmd  =x86.=parse_operand =@dest,dest\r
56                 check   @dest.type = 'mem'\r
57                 jyes    operand_ok\r
58                 asmcmd  =err 'invalid operand'\r
59                 exit\r
60             operand_ok:\r
61                 check   @dest.size and not 5\r
62                 jno     store_instruction\r
63                 asmcmd  =err 'invalid operand size'\r
64             store_instruction:\r
65                 asmcmd  =x86.=store_instruction <0Fh,1>,=@dest,postbyte\r
66                 exit\r
67         end calminstruction\r
69 end iterate\r
71 iterate <instr,ext>, lar,2, lsl,3\r
73         calminstruction instr? dest*,src*\r
74                 asmcmd  =x86.=parse_operand =@dest,dest\r
75                 asmcmd  =x86.=parse_operand =@src,src\r
76                 check   @dest.type = 'reg' & (@src.type = 'mem' | @src.type = 'reg')\r
77                 jno     invalid_combination_of_operands\r
78                 check   @src.size and not 2\r
79                 jno     size_ok\r
80                 asmcmd  =err 'invalid operand size'\r
81             size_ok:\r
82                 asmcmd  =x86.=store_instruction <0Fh,ext>,=@src,=@dest.=rm\r
83                 exit\r
84             invalid_combination_of_operands:\r
85                 asmcmd  =err 'invalid combination of operands'\r
86         end calminstruction\r
88 end iterate\r