├── .gitignore ├── LICENSE ├── README.MD └── original ├── BINW └── MSA2W.EXE ├── bin ├── MAKE.EXE └── MSA2.EXE ├── doc ├── CHANGES.TXT ├── DOC.TXT └── LICENSE ├── examples ├── FYR.ASM ├── MAKEFILE ├── MICED.ASM ├── OVL-TP7 │ ├── CALLER.EXE │ ├── CALLER.PAS │ ├── MAKEFILE │ ├── MYFN.ASM │ ├── MYFN.OVL │ ├── OVL.PAS │ └── README.TXT ├── PASSWORD.ASM ├── SNOW.ASM └── STAR.ASM └── src ├── ASSEMBLR.C ├── EXPR.C ├── EXPR.H ├── LEX.C ├── LEX.H ├── MAKEFILE ├── MISC.C ├── MSA.C ├── MSA2.H └── TABLES.C /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2000, 2001, 2019 Robert Ostling 4 | Copyright (c) 2019 DosWorld 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # MSA2 x86 assembler for real-mode DOS 2 | 3 | ooo ooooo .oooooo..o .o. .oooo. 4 | `88. .888' d8P' `Y8 .888. .dP""Y88b 5 | 888b d'888 Y88bo. .8"888. ]8P' 6 | 8 Y88. .P 888 `"Y8888o. .8' `888. .d8P' 7 | 8 `888' 888 `"Y88b .88ooo8888. .dP' 8 | 8 Y 888 oo .d8P .8' `888. .oP .o 9 | o8o o888o 8""88888P' o88o o8888o 8888888888 10 | 11 | **MSA2** is a old and free x86 two-pass assembler for DOS targets. 12 | It supports all Intel 8086 instructions and most of the 80186/80286 13 | instructions. 14 | 15 | Initialy written by a 14-year old Swedish programmer Robert Ostling 16 | (in 2000-2001) in Borland C++ 2.0. Now, MSA2 is ported to Watcom C 17 | and GCC (and/or mingw). 18 | 19 | **MSA2** Consume to small piece of memory - i think, will be enougth 20 | just 128K. MSA2 does not require DPMI. 21 | 22 | **MSA2** is pretty fast and the only file you'll need to build a program 23 | is MSA2.EXE (50 KB). It runs fine on my old 286. 24 | 25 | **MSA2** - has precompiled binary for DOS and win32. You can compile 26 | DOS programs in modern windows without DosBox. 27 | 28 | I had not test MSA2 in FreeDOS, Linux, windows yet, but there should 29 | not be any difference where running MSA2. 30 | 31 | To compile your source with MSA2 just type: 32 | 33 | MSA2 coolprog.asm -o coolprog.com 34 | 35 | ## Output formats 36 | 37 | **MSA2** produces next formats: 38 | 39 | * **-f bin** flat binary output 40 | * **-f com** .com file 41 | * **-f texe** .exe file with tiny memory model 42 | * **-f ovl** .ovl overlay file with tiny memory model (this is the same 43 | as texe, but with symbol table). 44 | 45 | Examples how to use overlays - see /original/examples/OVL-TP7/ folder. 46 | 47 | ## Differences with MSA 48 | 49 | * Added missed opcodes 50 | * Added .exe generation 51 | 52 | ## Differences with NASM 53 | 54 | * No macros / includes 55 | * No conditional jumps optimization (near/short) 56 | 57 | ## Build MSA2 58 | 59 | MSA2 could be compiled for DOS, Linux and windows with Open Watcom C, 60 | GCC, GCC/MINGW. 61 | 62 | ### DOS 63 | 64 | To build DOS version with Watcom C, just type (in original/src/) 65 | 66 | make 67 | 68 | or 69 | 70 | wmake 71 | 72 | ### Linux 73 | 74 | To build Linux version with GCC: 75 | 76 | gcc -O3 MSA.C TABLES.C ASSEMBLR.C MISC.C LEX.C -o MSA2 77 | strip MSA2 78 | 79 | ### windows 80 | 81 | To build win32 version with mingw: 82 | 83 | i686-w64-mingw32-gcc -m32 -O3 MSA.C TABLES.C ASSEMBLR.C MISC.C LEX.C -o MSA2W.EXE 84 | strip MSA2W.EXE 85 | 86 | ## License 87 | 88 | This is free software: you can redistribute it and/or modify it under 89 | the terms of the MIT license. See LICENSE file. 90 | -------------------------------------------------------------------------------- /original/BINW/MSA2W.EXE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DosWorld/msa2/1a2a5d685ef3a3c042e12fdb67dba57accebd967/original/BINW/MSA2W.EXE -------------------------------------------------------------------------------- /original/bin/MAKE.EXE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DosWorld/msa2/1a2a5d685ef3a3c042e12fdb67dba57accebd967/original/bin/MAKE.EXE -------------------------------------------------------------------------------- /original/bin/MSA2.EXE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DosWorld/msa2/1a2a5d685ef3a3c042e12fdb67dba57accebd967/original/bin/MSA2.EXE -------------------------------------------------------------------------------- /original/doc/CHANGES.TXT: -------------------------------------------------------------------------------- 1 | 2 | News in version 1.0.14: 3 | 4 | * Complete rewriten lexer 5 | 6 | News in version 1.0.13: 7 | 8 | * Increased speed x2/x4 times 9 | 10 | News in version 1.0.12: 11 | 12 | 00:03 14 Jan 2001 13 | * Char constant added. 14 | * Faster (does not write to disk if not final pass) 15 | 16 | 17 | 15:05 5 Jun 2001 18 | * BUILD.BAT able to make 8086 compatible code 19 | 20 | 21 | 01:02 6 Jun 2001 22 | * Install program written 23 | * A few small bugs fixed -------------------------------------------------------------------------------- /original/doc/DOC.TXT: -------------------------------------------------------------------------------- 1 | 2 | 3 | MSA2 1.0 (BUILD 14) 4 | -=-=-=-=-=-=-=-=-=- 5 | Copyright(C) 2000 - 2019 Robert Ostling (robost86@hotmail.com) 6 | Copyright(C) 2019 DosWord (dosworld@tutanota.com) 7 | -=-=-=-=-=-=-=-=-=- 8 | 9 | 10 | Copyright 11 | -=-=-=-=- 12 | 13 | This is free software: you can redistribute it and/or modify it under 14 | the terms of ther MIT license. See LICENSE file. 15 | 16 | 17 | Bugs? 18 | -=-=- 19 | 20 | When this package is released, there are no known bugs. If 21 | you discover a bug, or just want to come with a suggestion or 22 | a comment, just e-mail me (dosworld@tutanota.com). 23 | 24 | 25 | What's MSA? 26 | -=-=-=-=-=- 27 | 28 | MSA2 is a old free x86 assembler. It supports all 8086 29 | instructions and most of the 80186/80286 instructions. It 30 | supports formats: 31 | 32 | * flat binary output -fbin 33 | * .com file -fcom 34 | * .exe file with tiny memory model -ftexe. 35 | * .ovl overlay file with tiny memory model -fovl (this 36 | is the same as texe, but with symbol table). 37 | 38 | Initialy written by a 14-year old Swedish programmer (that's 39 | why my english isn't very good)-: 40 | 41 | MSA2 is pretty fast, and the only file you'll need to build 42 | a program is MSA2.EXE (50 KB). It runs fine on my old 286. 43 | MSA2 does not require DPMI. 44 | 45 | I wrote MSA2 in C, using Borland C++ 2.0, but I don't think 46 | it should be very hard to port to another compiler. The 47 | source code is not commented, not structured, so, it may 48 | be a little hard to read... Now, MSA2 is ported to Watcom C. 49 | 50 | I have not tested MSA2 in FreeDOS yet, but there should not 51 | be any difference between running MSA2 in a DOS box, real-mode 52 | MS-DOS or FreeDOS. 53 | 54 | 55 | System Requirements :-) 56 | -=-=-=-=-=-=-=-=-=- -=- 57 | 58 | MSA2 had been tested on the following computer, and it runs 59 | just fine. 60 | 61 | Toshiba 3100 62 | ============ 63 | 64 | CPU: 80286 65 | RAM: 640 KB 66 | HD: 10 MB 67 | OS: Toshiba DOS 5.0 68 | Screen: Small B/W plasma screen 69 | 70 | Your HD will not be filled just by installing MSA2... 71 | 72 | 168 KB (full installation) 73 | 35 KB (minimum installation) 74 | 75 | Using MSA 76 | -=-=-=-=- 77 | 78 | MSA2 is a command-line program, use your favourite editor to 79 | edit the source files. Here are a more detailed description 80 | of the different command-line options MSA2 supports. (These 81 | command-line options are case insensitive, like the rest of 82 | MSA2. 83 | 84 | ============================================================= 85 | 86 | -o - Set output file 87 | 88 | Use: -o file.com, -o disk.bin 89 | 90 | There can only be one output file per compile, if more than 91 | one output files are present, the last one will be used. If 92 | no output file is present, you'll see the built-in help screen. 93 | 94 | ============================================================= 95 | 96 | -s - Set starting point 97 | 98 | Use: -s 0, -s 0x7c00 99 | 100 | This is an optional command, if you don't use this option, 101 | the standard DOS .COM starting point (0x100) is used. 102 | 103 | ============================================================= 104 | 105 | -b - Set buffer size 106 | 107 | Use: -b 0x400, -b 0x100 108 | 109 | This option changes the size of the output buffer kept in 110 | memory. Should be a value between 0x100 (256) and 0x4000 111 | (16 KB). 112 | 113 | ============================================================= 114 | 115 | -m - Set output level 116 | 117 | Use: -m 0, -m 1, -m 2 118 | 119 | m0 means: "only report errors" 120 | m1 means: "only report errors and serious warnings" 121 | m2 means: "report all" 122 | 123 | ============================================================= 124 | 125 | -f - Set destination format 126 | 127 | Use: -f bin, -f com, -f texe, -f ovl 128 | 129 | fbin means: raw binary 130 | fcom means: DOS .com file 131 | ftexe means: DOS .exe file with tiny memory model 132 | fovl means: the same as texe but with symbol table at end 133 | 134 | ============================================================= 135 | 136 | -d - Predefine constant 137 | 138 | Use: -dVSEG=0xA000, -dDOS=1 139 | 140 | ============================================================= 141 | 142 | All other commands, not beginning with '-' will be assumed 143 | to be input files. 144 | 145 | ============================================================= 146 | 147 | 148 | The syntax of MSA 149 | -=-=-=-=-=-=-=-=- 150 | 151 | MSA:s syntax is similar to the syntax of NASM. I think every 152 | documented feature of MSA2 is supported by NASM, but this does 153 | _not_ mean that a NASM program always can be assebled by MSA2. 154 | For example, MSA2 has no 32-bit support and macros. 155 | 156 | Constants 157 | ========= 158 | 159 | There are two ways of declaring constants in MSA2. 160 | 161 | 1. ident EQU value 162 | 2. CONST ident value 163 | 164 | I recommend the first way, for compatibility with NASM. 165 | A constant value may use following operators: 166 | '+', '-', '*', '/' and '%' 167 | But NOT: 168 | '(' and ')' 169 | 170 | You may also use following constants: 171 | $ and $$ 172 | 173 | $ is the offset, $$ is the starting point 174 | 175 | You may only define integer constants, NOT floating point 176 | or string constants. 177 | 178 | Examples of valid constants: 179 | 180 | data_start EQU $+0x100 181 | my_sweet EQU 0x4*0x13 182 | lord EQU $$-0x80 183 | color EQU 0b1011 184 | 185 | Labels, DB, DW and DD 186 | ===================== 187 | 188 | 189 | In MSA, you define labels in the same way as you do in all 190 | programming languages, 191 | 192 | label: 193 | 194 | where 'label' is the name of your label. There is another way to 195 | define a label, only used with DB, DW and DD. This command: 196 | 197 | fname: DB "filename.dat",0 198 | idword: DW 0x51a0 199 | 200 | 201 | DB can be used to declare strings and 8-bit values: 202 | 203 | my_db: DB "this is a string",1,2,3,0x10,0x20,0x30,14%3 204 | 205 | 206 | DW is used only to declare 16-bit variables: 207 | 208 | my_dw: DW 0x2314,0x5214,0x5382,0x0000,4,1,6 209 | 210 | 211 | DD is used only to declare 32-bit variables: 212 | 213 | my_dd: DD 0x23a36b14,0x552814,0x5ba4382,0x1000000,4,51,6 214 | 215 | 216 | Comments 217 | ======== 218 | 219 | Ordninary assembler comments, one-line comments beginning with 220 | ';', are the only valid comments in MSA2. 221 | 222 | 223 | Opcodes 224 | ======= 225 | 226 | If you want to use the short opcodes for the 1-step 227 | bit shift/rotation instructions, you'll have to type: 228 | 229 | shl1 ax 230 | ror1 bl 231 | ... 232 | 233 | 234 | 23:31 24 Nov 2019 235 | -=-=-=-=-=-=-=-=- 236 | End of document 237 | -------------------------------------------------------------------------------- /original/doc/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2000, 2001, 2019 Robert Ostling 4 | Copyright (c) 2019 DosWorld 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /original/examples/FYR.ASM: -------------------------------------------------------------------------------- 1 | ; 2 | ; MIT License 3 | ; 4 | ; Copyright (c) 2000, 2001, 2019 Robert Ostling 5 | ; 6 | ; Permission is hereby granted, free of charge, to any person obtaining a copy 7 | ; of this software and associated documentation files (the "Software"), to deal 8 | ; in the Software without restriction, including without limitation the rights 9 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | ; copies of the Software, and to permit persons to whom the Software is 11 | ; furnished to do so, subject to the following conditions: 12 | ; 13 | ; The above copyright notice and this permission notice shall be included in all 14 | ; copies or substantial portions of the Software. 15 | ; 16 | ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | ; SOFTWARE. 23 | ; 24 | MOV AX,0X13 25 | INT 0X10 26 | MOV AX,0XA000 27 | MOV ES,AX 28 | 29 | MOV CX,0X40 30 | SETPAL0: MOV DX,0X03C8 31 | MOV AL,CL 32 | DEC AX 33 | OUT DX,AL 34 | INC DX 35 | OUT DX,AL 36 | XOR AL,AL 37 | OUT DX,AL 38 | OUT DX,AL 39 | LOOP SETPAL0 40 | 41 | MAIN_LOOP: 42 | MOV DI,320*199 43 | MOV CX,319 44 | L0: MOV DX,0X3F 45 | CALL RANDOM 46 | STOSB 47 | LOOP L0 48 | 49 | MOV DI,320*199-1 50 | L1: 51 | MOV AL,BYTE[ES:DI+320] 52 | MOV AH,0 53 | SHL AX,2 54 | L2: 55 | ADD AL,BYTE[ES:DI+321] 56 | ADC AH,0 57 | ADD AL,BYTE[ES:DI+319] 58 | ADC AH,0 59 | ADD AL,BYTE[ES:DI-319] 60 | ADC AH,0 61 | ADD AL,BYTE[ES:DI-321] 62 | ADC AH,0 63 | INC AX 64 | SHR AX,3 65 | MOV BYTE[ES:DI],AL 66 | OR AL,AL 67 | JNZ J3 68 | INC CX 69 | CMP CX,320 70 | JA J1 71 | JMP SHORT J4 72 | 73 | J3: 74 | XOR CX,CX 75 | J4: 76 | 77 | DEC DI 78 | CMP DI,0XFFFF 79 | JNZ L1 80 | 81 | J1: MOV AH,1 82 | INT 0X16 83 | JZ MAIN_LOOP 84 | 85 | MOV AH,0 86 | INT 0X16 87 | MOV AX,3 88 | INT 0X10 89 | INT 0X20 90 | 91 | RANDOM: MOV AH,BYTE[RSEED+1] 92 | IN AL,0X40 93 | XOR AH,AL 94 | ROR AH,1 95 | XOR AL,AH 96 | MOV BYTE[RSEED],AL 97 | IN AL,0X40 98 | ROR AX,4 99 | XOR AL,AH 100 | MOV BYTE[RSEED+1],AL 101 | MOV AX,WORD[RSEED] 102 | PUSH CX 103 | MOV CX,DX 104 | XOR DX,DX 105 | DIV CX 106 | MOV AX,DX 107 | POP CX 108 | RET 109 | 110 | RSEED: DW 0X5A8B 111 | -------------------------------------------------------------------------------- /original/examples/MAKEFILE: -------------------------------------------------------------------------------- 1 | all: FYR.COM MICED.COM PASSWORD.COM SNOW.COM STAR.COM BRICK.COM 2 | 3 | FYR.COM: FYR.ASM 4 | MSA2 FYR.ASM -o FYR.COM 5 | 6 | MICED.COM: MICED.ASM 7 | MSA2 MICED.ASM -o MICED.COM 8 | 9 | PASSWORD.COM: PASSWORD.ASM 10 | MSA2 PASSWORD.ASM -o PASSWORD.COM 11 | 12 | SNOW.COM: SNOW.ASM 13 | MSA2 SNOW.ASM -o SNOW.COM 14 | 15 | STAR.COM: STAR.ASM 16 | MSA2 STAR.ASM -o STAR.EXE -f texe 17 | 18 | BRICK.COM: BRICK.ASM 19 | MSA2 BRICK.ASM -o BRICK.COM 20 | 21 | clean: 22 | DEL *.COM 23 | DEL *.EXE 24 | 25 | prof: 26 | DEL *.SMP 27 | WSAMPLE MSA2.EXE MICED.ASM -o MICED.COM 28 | COPY MSA2.SMP MICED.SMP 29 | WSAMPLE MSA2.EXE SNOW.ASM -o SNOW.COM 30 | COPY MSA2.SMP SNOW.SMP 31 | DEL MSA2.SMP 32 | -------------------------------------------------------------------------------- /original/examples/MICED.ASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DosWorld/msa2/1a2a5d685ef3a3c042e12fdb67dba57accebd967/original/examples/MICED.ASM -------------------------------------------------------------------------------- /original/examples/OVL-TP7/CALLER.EXE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DosWorld/msa2/1a2a5d685ef3a3c042e12fdb67dba57accebd967/original/examples/OVL-TP7/CALLER.EXE -------------------------------------------------------------------------------- /original/examples/OVL-TP7/CALLER.PAS: -------------------------------------------------------------------------------- 1 | { 2 | 3 | MIT License 4 | 5 | Copyright (c) 2019 DosWorld 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | Part of the MSA assembler 26 | 27 | } 28 | {$M 16000,0,0} 29 | uses ovl; 30 | 31 | {$F+} 32 | 33 | type 34 | TMyProc = function:integer; 35 | TPutc = procedure(a:char); 36 | 37 | var 38 | o :tovl; 39 | fn :TMyProc; 40 | putc :TPutc; 41 | 42 | procedure puts(s:string); 43 | var i:byte; 44 | begin 45 | for i:=1 to ord(s[0]) do putc(s[i]); 46 | end; 47 | 48 | begin 49 | 50 | if not ovl_load(o, 'myfn.ovl') then 51 | begin 52 | writeln('Error while load overlay.'); 53 | halt(1); 54 | end; 55 | 56 | writeln('Overlay loaded.'); 57 | 58 | 59 | if ovl_find(o, 'TESTFN', @fn) then begin 60 | writeln('Overlay function TESTFN return ', fn, '.'); 61 | end else begin 62 | writeln('Error - function TESTFN not found.'); 63 | end; 64 | 65 | if ovl_find(o, 'PUTC', @putc) then puts('>> This print with overlay function PUTC.'+#13+#10); 66 | 67 | writeln('Unload overlay.'); 68 | 69 | ovl_unload(o); 70 | 71 | writeln('Done.'); 72 | 73 | end. -------------------------------------------------------------------------------- /original/examples/OVL-TP7/MAKEFILE: -------------------------------------------------------------------------------- 1 | all: MYFN.OVL CALLER.EXE 2 | 3 | MYFN.OVL: MYFN.ASM 4 | MSA2 MYFN.ASM -oMYFN.OVL -fovl 5 | 6 | CALLER.EXE: CALLER.PAS OVL.PAS 7 | TPC /M CALLER.PAS 8 | 9 | clean: 10 | DEL *.EXE 11 | DEL *.TPU 12 | DEL *.OVL 13 | -------------------------------------------------------------------------------- /original/examples/OVL-TP7/MYFN.ASM: -------------------------------------------------------------------------------- 1 | ; 2 | ; 3 | ; MIT License 4 | ; 5 | ; Copyright (c) 2019 DosWorld 6 | ; 7 | ; Permission is hereby granted, free of charge, to any person obtaining a copy 8 | ; of this software and associated documentation files (the "Software"), to deal 9 | ; in the Software without restriction, including without limitation the rights 10 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | ; copies of the Software, and to permit persons to whom the Software is 12 | ; furnished to do so, subject to the following conditions: 13 | ; 14 | ; The above copyright notice and this permission notice shall be included in all 15 | ; copies or substantial portions of the Software. 16 | ; 17 | ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | ; SOFTWARE. 24 | ; 25 | ; Part of the MSA assembler 26 | ; 27 | 28 | testfn: 29 | MOV AX,44 30 | RETF 31 | putc: 32 | push bp 33 | mov bp,sp 34 | mov dl,byte[ss:bp+6] 35 | mov ah,2 36 | int 0x21 37 | mov sp,bp 38 | pop bp 39 | retf 2 40 | 41 | export testfn 42 | export putc 43 | -------------------------------------------------------------------------------- /original/examples/OVL-TP7/MYFN.OVL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DosWorld/msa2/1a2a5d685ef3a3c042e12fdb67dba57accebd967/original/examples/OVL-TP7/MYFN.OVL -------------------------------------------------------------------------------- /original/examples/OVL-TP7/OVL.PAS: -------------------------------------------------------------------------------- 1 | { 2 | 3 | MIT License 4 | 5 | Copyright (c) 2019 DosWorld 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | Part of the MSA assembler 26 | 27 | } 28 | unit ovl; 29 | {$F+} 30 | 31 | interface 32 | 33 | type 34 | 35 | TOvl = record 36 | aseg :word; 37 | stab :word; 38 | stab_hdr :array[0..2] of word; 39 | end; 40 | 41 | function ovl_load(var ovlrec:TOvl; fname:string):boolean; 42 | procedure ovl_unload(var ovlrec:TOvl); 43 | function ovl_find(var ovlrec:TOvl; funcname:pchar;var p:pointer):boolean; 44 | 45 | implementation 46 | 47 | const 48 | MAGIK = $FE33; 49 | SYMBOL_LEN = 32; 50 | 51 | function DosGetMem(count:word):word; 52 | begin 53 | if (count and $f) <> 0 then count := (count shr 4) + 1 54 | else count := count shr 4; 55 | asm 56 | push es 57 | push ds 58 | push bp 59 | mov bx,count 60 | mov ah,48h 61 | int 21h 62 | jnc @c1 63 | xor ax,ax 64 | @c1: 65 | pop bp 66 | pop ds 67 | pop es 68 | mov count,ax 69 | end; 70 | DosGetMem := count; 71 | end; 72 | 73 | procedure DosFreeMem(aseg:word);assembler; 74 | asm 75 | mov ax,aseg 76 | or ax,ax 77 | jz @c2 78 | push es 79 | push ds 80 | push bp 81 | mov es,ax 82 | mov ah,49h 83 | int 21h 84 | pop bp 85 | pop ds 86 | pop es 87 | @c2: 88 | end; 89 | 90 | function ovl_load(var ovlrec:TOvl; fname:string):boolean; 91 | var exe_hdr:array[0..31] of byte; 92 | bss_size, lblock_size:word; 93 | code_size:longint; 94 | stab_hdr:array[0..2] of word; 95 | f:file; 96 | r:boolean; 97 | exe_ofs, stab_ofs:longint; 98 | begin 99 | r := false; 100 | ovlrec.aseg := 0; 101 | ovlrec.stab := 0; 102 | {$I-} 103 | assign(f, fname); 104 | reset(f,1); 105 | {$I+} 106 | if ioresult = 0 then 107 | begin 108 | blockread(f, exe_hdr, 32); 109 | lblock_size := (exe_hdr[2] or (exe_hdr[3] shl 8)); 110 | bss_size := ((exe_hdr[$0a] and $ff) or ((exe_hdr[$0b] and $ff) shl 8)); 111 | code_size := (exe_hdr[4] or (exe_hdr[5] shl 8)) * 512; 112 | if lblock_size <> 0 then dec(code_size, 512 - lblock_size); 113 | 114 | exe_ofs := (exe_hdr[8] or (exe_hdr[9] shl 8)) * 16; 115 | stab_ofs := exe_ofs + code_size; 116 | ovlrec.aseg := DosGetMem(code_size + bss_size * 512); 117 | if ovlrec.aseg <> 0 then 118 | begin 119 | {$I-} 120 | seek(f, exe_ofs); 121 | blockread(f, mem[ovlrec.aseg:0], code_size); 122 | seek(f, stab_ofs); 123 | blockread(f, ovlrec.stab_hdr, 6); 124 | {$I+} 125 | if (ovlrec.stab_hdr[0] = MAGIK) and (ioresult = 0) then 126 | begin 127 | ovlrec.stab := DosGetMem(ovlrec.stab_hdr[2]); 128 | if ovlrec.stab<>0 then 129 | begin 130 | {$I-} 131 | blockread(f, mem[ovlrec.stab:0], ovlrec.stab_hdr[2]); 132 | {$I+} 133 | r := true; 134 | end; 135 | end; 136 | end; 137 | close(f); 138 | end; 139 | if not r then ovl_unload(ovlrec); 140 | ovl_load := r; 141 | end; 142 | 143 | procedure ovl_unload(var ovlrec:TOvl); 144 | begin 145 | DosFreeMem(ovlrec.aseg); 146 | DosFreeMem(ovlrec.stab); 147 | ovlrec.aseg := 0; 148 | ovlrec.stab := 0; 149 | end; 150 | 151 | function cmp(p1, p2 :pchar; len:integer):boolean; 152 | var r:boolean; 153 | i:integer; 154 | begin 155 | r := false; 156 | i := 0; 157 | while i < len do 158 | begin 159 | if upcase(p1[i]) <> upcase(p2[i]) then break; 160 | if p2[i] = #0 then 161 | begin 162 | r := true; 163 | break; 164 | end; 165 | inc(i); 166 | end; 167 | cmp := r; 168 | end; 169 | 170 | function ovl_find(var ovlrec:TOvl; funcname:pchar;var p:pointer):boolean; 171 | var 172 | r :boolean; 173 | i :integer; 174 | ofs:word; 175 | begin 176 | r := false; 177 | p := nil; 178 | if (ovlrec.aseg<>0) and (ovlrec.stab<>0) and (ovlrec.stab_hdr[1]<>0) then 179 | begin 180 | for i:= 0 to ovlrec.stab_hdr[1] - 1 do 181 | begin 182 | if cmp(@mem[ovlrec.stab:i*36], funcname, SYMBOL_LEN) then 183 | begin 184 | ofs := (mem[ovlrec.stab:i*36+32] and $ff) or (mem[ovlrec.stab:i*36+33] and $ff) shl 8; 185 | p := ptr(ovlrec.aseg, ofs); 186 | r := true; 187 | break; 188 | end; 189 | end; 190 | end; 191 | ovl_find := r; 192 | end; 193 | 194 | end. 195 | -------------------------------------------------------------------------------- /original/examples/OVL-TP7/README.TXT: -------------------------------------------------------------------------------- 1 | 2 | Here is example how to use overlay with TP6/TP7. 3 | 4 | === 5 | 6 | 1. Borland has own engine for overlays, but for some cases 7 | it could be usefull - for example, for some reasons BGI 8 | does not use standart overlays. 9 | 10 | 2. Turbo Pascal is universal programming language - it 11 | is easy way how to explain usage model. 12 | 13 | So.. 14 | 15 | In this example CALLER.PAS load MYFN.OVL and call two 16 | functions: TESTFN and PUTC. 17 | 18 | === 19 | 20 | MSA2 overlays does not describe how to parameters 21 | must be passed to overlay, so you can use with 22 | your programming language convention. 23 | 24 | In this example - used pascal convention with far calls. 25 | 26 | === 27 | 28 | To build this example - type 'make', or 29 | 30 | compile overlay with: 31 | 32 | MSA2 MYFN.ASM -oMYFN.OVL -fovl 33 | 34 | compile pascal sources: 35 | 36 | TPC /M CALLER.PAS 37 | -------------------------------------------------------------------------------- /original/examples/PASSWORD.ASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DosWorld/msa2/1a2a5d685ef3a3c042e12fdb67dba57accebd967/original/examples/PASSWORD.ASM -------------------------------------------------------------------------------- /original/examples/SNOW.ASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DosWorld/msa2/1a2a5d685ef3a3c042e12fdb67dba57accebd967/original/examples/SNOW.ASM -------------------------------------------------------------------------------- /original/examples/STAR.ASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DosWorld/msa2/1a2a5d685ef3a3c042e12fdb67dba57accebd967/original/examples/STAR.ASM -------------------------------------------------------------------------------- /original/src/ASSEMBLR.C: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2000, 2001, 2019 Robert Ostling 6 | Copyright (c) 2019 DosWorld 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | 26 | Part of the MSA2 assembler 27 | 28 | */ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include "MSA2.H" 35 | #include "LEX.H" 36 | #include "EXPR.H" 37 | 38 | long int fsize; 39 | long int linenr; 40 | word old_outptr; 41 | char *param[2]; 42 | int param_type[2]; 43 | int params; 44 | 45 | inline void out_word(int x) { 46 | outprog[outptr++] = x & 0xff; 47 | outprog[outptr++] = (char)(x >> 8) & 0xff; 48 | } 49 | 50 | inline void out_long(long int x) { 51 | outprog[outptr++] = x & 0xff; 52 | outprog[outptr++] = (char)(x >> 8) & 0xff; 53 | outprog[outptr++] = (char)(x >> 16) & 0xff; 54 | outprog[outptr++] = (char)(x >> 24) & 0xff; 55 | } 56 | 57 | char match_params(t_instruction *cinstr, int pcount) { 58 | int k, type, t; 59 | 60 | for(k = 0; k < pcount; k++) { 61 | type = param_type[k]; 62 | switch(t = cinstr->param_type[k]) { 63 | case RM_8: 64 | if(type !=MEM_8 && (type < ACC_8 || type > BH)) { 65 | return 0; 66 | } 67 | break; 68 | case RM_16: 69 | if(type != MEM_16 && (type < ACC_16 || type >= SEG)) { 70 | return 0; 71 | } 72 | break; 73 | case REG_8: 74 | if(type < ACC_8 || type >= ACC_16) { 75 | return 0; 76 | } 77 | break; 78 | case REG_16: 79 | if((type < ACC_16 || type >= SEG)) { 80 | return 0; 81 | } 82 | break; 83 | case REG_SEG: 84 | if((type < SEG || type > DS)) { 85 | return 0; 86 | } 87 | break; 88 | default: 89 | if(type != t) { 90 | return 0; 91 | } 92 | break; 93 | } 94 | } 95 | return 1; 96 | } 97 | 98 | inline char getReg(int r, int min, int max, const char *msg) { 99 | if(r < min || r > max) { 100 | out_msg(msg, 0); 101 | return 0; 102 | } 103 | return r - min; 104 | } 105 | 106 | inline void do_instruction(t_instruction *cinstr) { 107 | t_address addr; 108 | int k, cf, j = 0; 109 | int op1, op2, pt1, pt2; 110 | long z; 111 | 112 | while(cinstr->op[j] != 0) { 113 | op1 = cinstr->op[j + 1]; 114 | op2 = cinstr->op[j + 2]; 115 | pt1 = param_type[op1]; 116 | pt2 = param_type[op2]; 117 | switch(cinstr->op[j]) { 118 | case OP_CMD_OP: 119 | outprog[outptr++] = op1; 120 | break; 121 | case OP_CMD_IMM8: 122 | outprog[outptr++] = get_const(param[op1]); 123 | break; 124 | case OP_CMD_IMM16: 125 | out_word(get_const(param[op1])); 126 | break; 127 | case OP_CMD_PLUSREG8: 128 | outprog[outptr++] = op1 + getReg(pt2, ACC_8, BH, "Syntax error, expected reg8"); 129 | j++; 130 | break; 131 | case OP_CMD_PLUSREG16: 132 | outprog[outptr++] = op1 + getReg(pt2, ACC_16, DI, "Syntax error, expected reg16"); 133 | j++; 134 | break; 135 | case OP_CMD_PLUSREGSEG: 136 | outprog[outptr++] = op1 + getReg(pt2, SEG, DS, "Syntax error, expected segreg"); 137 | j++; 138 | break; 139 | case OP_CMD_RM1_8: 140 | get_address(&addr, param[op1]); 141 | addr.reg = getReg(pt2, ACC_8, BH, "Syntax error, expected reg8"); 142 | build_address(&addr); 143 | memcpy(outprog + outptr, &addr.op, addr.op_len); 144 | outptr += addr.op_len; 145 | j++; 146 | break; 147 | case OP_CMD_RM1_16: 148 | get_address(&addr, param[op1]); 149 | addr.reg = getReg(pt2, ACC_16, DI, "Syntax error, expected reg16"); 150 | build_address(&addr); 151 | memcpy(outprog + outptr, &addr.op, addr.op_len); 152 | outptr += addr.op_len; 153 | j++; 154 | break; 155 | case OP_CMD_RM2_8: 156 | get_address(&addr, param[op2]); 157 | addr.reg = getReg(pt1, ACC_8, BH, "Syntax error, expected reg8"); 158 | build_address(&addr); 159 | memcpy(outprog + outptr, &addr.op, addr.op_len); 160 | outptr += addr.op_len; 161 | j++; 162 | break; 163 | case OP_CMD_RM2_16: 164 | get_address(&addr, param[op2]); 165 | addr.reg = getReg(pt1, ACC_16, DI, "Syntax error, expected reg16"); 166 | build_address(&addr); 167 | memcpy(outprog + outptr, &addr.op, addr.op_len); 168 | outptr += addr.op_len; 169 | j++; 170 | break; 171 | case OP_CMD_RM2_SEG: 172 | get_address(&addr, param[op2]); 173 | addr.reg = getReg(pt1, SEG, DS, "Syntax error, expected segreg"); 174 | build_address(&addr); 175 | memcpy(outprog + outptr, &addr.op, addr.op_len); 176 | outptr += addr.op_len; 177 | j++; 178 | break; 179 | case OP_CMD_RM1_SEG: 180 | get_address(&addr, param[op1]); 181 | addr.reg = getReg(pt2, SEG, DS, "Syntax error, expected segreg"); 182 | build_address(&addr); 183 | memcpy(outprog + outptr, &addr.op, addr.op_len); 184 | outptr += addr.op_len; 185 | j++; 186 | break; 187 | case OP_CMD_RMLINE_8: 188 | get_address(&addr, param[op2]); 189 | addr.reg = op1; 190 | build_address(&addr); 191 | memcpy(outprog + outptr, &addr.op, addr.op_len); 192 | outptr += addr.op_len; 193 | j++; 194 | break; 195 | case OP_CMD_RMLINE_16: 196 | get_address(&addr, param[op2]); 197 | addr.reg = op1; 198 | build_address(&addr); 199 | memcpy(outprog + outptr, &addr.op, addr.op_len); 200 | outptr += addr.op_len; 201 | j++; 202 | break; 203 | case OP_CMD_REL8: 204 | if(abs(z = get_const(param[op1]) - (outptr + 1)) > 127 && pass) { 205 | out_msg("Too long jump", 1); 206 | } 207 | outprog[outptr++] = z & 0xff; 208 | break; 209 | case OP_CMD_REL16: 210 | out_word(get_const(param[op1])-(outptr + 2)); 211 | break; 212 | } 213 | j += 2; 214 | } 215 | } 216 | 217 | int assemble(char* fname) { 218 | FILE *infile; 219 | char *line, *a1, *p; 220 | t_line *cur; 221 | char cf, stop, found; 222 | int j, l, prescan; 223 | t_constant *org_const, *ofs_const, *c; 224 | long int lvalue; 225 | int lex1, lex2; 226 | t_instruction *cinstr; 227 | 228 | if((infile = fopen(fname,"rb")) == NULL) { 229 | out_msg("Can't open input file", 0); 230 | return 0; 231 | } 232 | 233 | a1 = line = NULL; 234 | linenr = 0; 235 | stop = 0; 236 | 237 | ofs_const = find_const("$"); 238 | org_const = find_const("$$"); 239 | 240 | cur = (t_line *)MSA_MALLOC(sizeof(t_line)); 241 | line = (char *)MSA_MALLOC(4096); 242 | a1 = (char *)MSA_MALLOC(4096); 243 | param[0] = cur->p1; 244 | param[1] = cur->p2; 245 | 246 | while(fgets(line, 4095, infile) && (!stop)) { 247 | linenr++; 248 | strip_line(line); 249 | 250 | memset(cur, 0, sizeof(t_line)); 251 | split_line(cur, line, a1); 252 | 253 | ofs_const->value = outptr; 254 | 255 | if(cur->has_label) { 256 | add_const(cur->label, CONST_LABEL, outptr); 257 | } 258 | 259 | if(cur->has_lock) { 260 | outprog[outptr++] = 0xf0; 261 | } 262 | 263 | switch(cur->rep_type) { 264 | case LEX_REP: 265 | outprog[outptr++] = 0xf3; 266 | break; 267 | case LEX_REPNZ: 268 | outprog[outptr++] = 0xf2; 269 | break; 270 | } 271 | 272 | if(cur->cmd[0] == 0) { 273 | continue; 274 | } 275 | 276 | // printf("[%li] [%s]:\t[%s]\t[%s],[%s]\n", linenr, cur->label, cur->cmd, cur->p1, cur->p2); 277 | 278 | lex1 = lookupLex(cur->cmd, &prescan); 279 | 280 | switch(lex1) { 281 | case LEX_DD: 282 | p = cur->p1; 283 | while(*p) { 284 | p = get_dword(p, &lvalue); 285 | out_long(lvalue); 286 | if(*p == ',') { 287 | p++; 288 | } else { 289 | break; 290 | } 291 | } 292 | break; 293 | case LEX_DW: 294 | l = 0; 295 | p = cur->p1; 296 | while(*p) { 297 | if(*p == ',') { 298 | a1[l] = 0; 299 | out_word(get_const(a1)); 300 | l = 0; 301 | } else { 302 | a1[l++] = *p; 303 | } 304 | p++; 305 | } 306 | a1[l] = 0; 307 | if(l != 0) { 308 | out_word(get_const(a1)); 309 | } 310 | break; 311 | case LEX_DB: 312 | p = cur->p1; 313 | l = 0; 314 | cf = 0; 315 | while(*p) { 316 | if(*p == ',' && !cf) { 317 | a1[l] = 0; 318 | if(l == 0) { 319 | p++; 320 | cf = 0; 321 | } else { 322 | outprog[outptr++] = get_const(a1); 323 | p++; 324 | } 325 | if(*p == '\"') { 326 | cf = 1; 327 | l = 0; 328 | } else { 329 | cf = 0; 330 | l = 0; 331 | a1[l++] = *p; 332 | } 333 | } else { 334 | if(*p == '\"') { 335 | cf ^= 1; 336 | } else { 337 | if(cf) { 338 | outprog[outptr++] = *p; 339 | } else { 340 | a1[l++] = *p; 341 | } 342 | } 343 | } 344 | p++; 345 | } 346 | a1[l] = 0; 347 | if(!cf) { 348 | outprog[outptr++] = get_const(a1); 349 | } 350 | break; 351 | case LEX_EXPORT: 352 | if((c = find_const(cur->p1)) != NULL) { 353 | c->is_export = 1; 354 | } 355 | break; 356 | case LEX_ORG: 357 | if(is_org_def) { 358 | out_msg("Org already defined and could not be changed", 0); 359 | } else { 360 | outptr = org = get_const(cur->p1); 361 | org_const->value = org; 362 | } 363 | break; 364 | case LEX_END: 365 | entry_point = get_const(cur->p1); 366 | entry_point_def = 1; 367 | stop = 1; 368 | break; 369 | case LEX_EQU: 370 | add_const(cur->label, CONST_EXPR, get_const(cur->p1)); 371 | break; 372 | case LEX_NONE: 373 | out_msg("Syntax error", 0); 374 | stop = 1; 375 | break; 376 | default: 377 | old_outptr = outptr; 378 | 379 | cinstr = &instr86[prescan]; 380 | 381 | param_type[0] = cur->pcount > 0 ? get_type(param[0]) : 0; 382 | param_type[1] = cur->pcount > 1 ? get_type(param[1]) : 0; 383 | 384 | lex2 = cur->lex2; 385 | found = 0; 386 | 387 | while(cinstr->lex1 != LEX_NONE && !found) { 388 | if(lex1 != cinstr->lex1) { 389 | break; 390 | } 391 | if(lex1 != cinstr->lex1 || (cinstr->lex2 != LEX_NONE && lex2 != cinstr->lex2)) { 392 | cinstr++; 393 | continue; 394 | } 395 | if((cur->pcount != cinstr->params) || !match_params(cinstr, cur->pcount)) { 396 | cinstr++; 397 | continue; 398 | } 399 | found = 1; 400 | do_instruction(cinstr); 401 | break; 402 | } 403 | if(!found) { 404 | out_msg("Syntax error", 0); 405 | } 406 | } 407 | } 408 | free(line); 409 | free(a1); 410 | fclose(infile); 411 | return 1; 412 | } 413 | -------------------------------------------------------------------------------- /original/src/EXPR.C: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2019 DosWorld 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | Part of the MSA2 assembler 26 | 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include "MSA2.H" 35 | #include "EXPR.H" 36 | 37 | t_constant *constants; 38 | 39 | void expr_init() { 40 | constants = NULL; 41 | } 42 | 43 | void expr_done() { 44 | t_constant *c; 45 | 46 | while(constants != NULL) { 47 | c = (t_constant *)constants->next; 48 | free(constants); 49 | constants = c; 50 | } 51 | } 52 | 53 | t_constant *add_const(const char* name, int type, int value) { 54 | t_constant *c; 55 | int hash; 56 | 57 | c = constants; 58 | hash = hashCode(name); 59 | 60 | while(c != NULL) { 61 | if(hash == c->hash) { 62 | if(!strcmp(c->name, name)) { 63 | if(value != c->value) { 64 | if((!pass && type == CONST_LABEL) || (pass && type == CONST_EXPR)) { 65 | sprintf(err_msg, "Constant %s changed", name); 66 | out_msg(err_msg, 2); 67 | } 68 | } 69 | c->value = value; 70 | c->type = type; 71 | return c; 72 | } 73 | } 74 | c = (t_constant *)c->next; 75 | } 76 | 77 | c = (t_constant *)MSA_MALLOC(sizeof(t_constant)); 78 | strcpy(c->name, name); 79 | c->value = value; 80 | c->hash = hash; 81 | c->type = type; 82 | c->is_export = 0; 83 | c->next = constants; 84 | return constants = c; 85 | } 86 | 87 | t_constant *find_const(const char *name) { 88 | t_constant *c; 89 | int hash; 90 | 91 | c = constants; 92 | hash = hashCode(name); 93 | while(c != NULL) { 94 | if(hash == c->hash) { 95 | if(!strcmp(c->name, name)) { 96 | break; 97 | } 98 | } 99 | c = (t_constant *)c->next; 100 | } 101 | return c; 102 | } 103 | -------------------------------------------------------------------------------- /original/src/EXPR.H: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2019 DosWorld 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | Part of the MSA2 assembler 26 | 27 | */ 28 | 29 | #ifndef _EXPR_H_ 30 | #define _EXPR_H_ 31 | 32 | extern t_constant *constants; 33 | 34 | extern void expr_init(); 35 | extern void expr_done(); 36 | 37 | extern t_constant *add_const(const char* name, int type, int value); 38 | extern t_constant *find_const(const char *name); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /original/src/LEX.C: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2019 DosWorld 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | Part of the MSA2 assembler 26 | 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include "MSA2.H" 34 | #include "LEX.H" 35 | 36 | int lexId[192]; 37 | int lexHash[192]; 38 | int lexPreScan[192]; 39 | const char *lexStr[192]; 40 | int lexPtr; 41 | 42 | void addLex(int id, const char *str) { 43 | int i; 44 | lexId[lexPtr] = id; 45 | lexStr[lexPtr] = str; 46 | lexHash[lexPtr] = hashCode(str); 47 | lexPreScan[lexPtr] = i = 0; 48 | 49 | while(instr86[i].lex1 != LEX_NONE) { 50 | if(instr86[i].lex1 == id) { 51 | lexPreScan[lexPtr] = i; 52 | break; 53 | } 54 | i++; 55 | } 56 | lexPtr++; 57 | } 58 | 59 | int lookupLex(const char *str, int *prescan) { 60 | int i, hash; 61 | 62 | if(*str == 0) { 63 | return LEX_NONE; 64 | } 65 | 66 | hash = hashCode(str); 67 | for(i = 0; i < lexPtr; i++) { 68 | if(hash == lexHash[i]) { 69 | if(!strcmp(lexStr[i], str)) { 70 | *prescan = lexPreScan[i]; 71 | return lexId[i]; 72 | } 73 | } 74 | } 75 | 76 | *prescan = 0; 77 | return LEX_NONE; 78 | } 79 | 80 | void lex_init() { 81 | lexPtr = 0; 82 | 83 | addLex(LEX_MOV, "MOV"); 84 | addLex(LEX_XOR, "XOR"); 85 | addLex(LEX_CMP, "CMP"); 86 | addLex(LEX_ADD, "ADD"); 87 | addLex(LEX_SUB, "SUB"); 88 | addLex(LEX_PUSH, "PUSH"); 89 | addLex(LEX_POP, "POP"); 90 | addLex(LEX_INC, "INC"); 91 | addLex(LEX_DEC, "DEC"); 92 | addLex(LEX_OR, "OR"); 93 | addLex(LEX_AND, "AND"); 94 | addLex(LEX_IDIV, "IDIV"); 95 | addLex(LEX_DIV, "DIV"); 96 | addLex(LEX_IMUL,"IMUL"); 97 | addLex(LEX_MUL, "MUL"); 98 | addLex(LEX_TEST, "TEST"); 99 | addLex(LEX_XCHG, "XCHG"); 100 | addLex(LEX_JMP, "JMP"); 101 | addLex(LEX_CALL, "CALL"); 102 | addLex(LEX_NEG, "NEG"); 103 | addLex(LEX_NOT, "NOT"); 104 | addLex(LEX_NOP, "NOP"); 105 | 106 | addLex(LEX_CMPSB, "CMPSB"); 107 | addLex(LEX_CMPSW, "CMPSW"); 108 | addLex(LEX_STOSB, "STOSB"); 109 | addLex(LEX_STOSW, "STOSW"); 110 | addLex(LEX_MOVSB, "MOVSB"); 111 | addLex(LEX_MOVSW, "MOVSW"); 112 | addLex(LEX_LODSB, "LODSB"); 113 | addLex(LEX_LODSW, "LODSW"); 114 | addLex(LEX_SCASB, "SCASB"); 115 | addLex(LEX_SCASW, "SCASW"); 116 | 117 | addLex(LEX_POPA, "POPA"); 118 | addLex(LEX_POPF, "POPF"); 119 | addLex(LEX_PUSHA, "PUSHA"); 120 | addLex(LEX_PUSHF, "PUSHF"); 121 | 122 | addLex(LEX_CBW, "CBW"); 123 | addLex(LEX_CWD, "CWD"); 124 | addLex(LEX_CLC, "CLC"); 125 | addLex(LEX_CLD, "CLD"); 126 | addLex(LEX_CLI, "CLI"); 127 | addLex(LEX_ENTER, "ENTER"); 128 | addLex(LEX_HALT, "HALT"); 129 | addLex(LEX_INTO, "INTO"); 130 | addLex(LEX_IRET, "IRET"); 131 | addLex(LEX_JCXZ, "JCXZ"); 132 | addLex(LEX_JA, "JA"); 133 | addLex(LEX_JAE, "JAE"); 134 | addLex(LEX_JB, "JB"); 135 | addLex(LEX_JBE, "JBE"); 136 | addLex(LEX_JC, "JC"); 137 | addLex(LEX_JE, "JE"); 138 | addLex(LEX_JG, "JG"); 139 | addLex(LEX_JGE, "JGE"); 140 | addLex(LEX_JL, "JL"); 141 | addLex(LEX_JLE, "JLE"); 142 | addLex(LEX_JNA, "JNA"); 143 | addLex(LEX_JNAE, "JNAE"); 144 | addLex(LEX_JNB, "JNB"); 145 | addLex(LEX_JNBE, "JNBE"); 146 | addLex(LEX_JNC, "JNC"); 147 | addLex(LEX_JNE, "JNE"); 148 | addLex(LEX_JNG, "JNG"); 149 | addLex(LEX_JNGE, "JNGE"); 150 | addLex(LEX_JLG, "JLG"); 151 | addLex(LEX_JNL, "JNL"); 152 | addLex(LEX_JNLE, "JNLE"); 153 | addLex(LEX_JNO, "JNO"); 154 | addLex(LEX_JNP, "JNP"); 155 | addLex(LEX_JNS, "JNS"); 156 | addLex(LEX_JNZ, "JNZ"); 157 | addLex(LEX_JO, "JO"); 158 | addLex(LEX_JP, "JP"); 159 | addLex(LEX_JPE, "JPE"); 160 | addLex(LEX_JPO, "JPO"); 161 | addLex(LEX_JS, "JS"); 162 | addLex(LEX_JZ, "JZ"); 163 | addLex(LEX_LDS, "LDS"); 164 | addLex(LEX_LES, "LES"); 165 | addLex(LEX_LEA, "LEA"); 166 | addLex(LEX_LEAVE, "LEAVE"); 167 | addLex(LEX_LOOP, "LOOP"); 168 | addLex(LEX_LOOPE, "LOPOPE"); 169 | addLex(LEX_LOOPNE, "LOOPNE"); 170 | addLex(LEX_LOOPZ, "LOOPZ"); 171 | addLex(LEX_LOOPNZ, "LOOPNZ"); 172 | addLex(LEX_IN, "IN"); 173 | addLex(LEX_OUT, "OUT"); 174 | 175 | addLex(LEX_REP, "REP"); 176 | addLex(LEX_REP, "REPE"); 177 | addLex(LEX_REP, "REPZ"); 178 | addLex(LEX_REPNZ, "REPNE"); 179 | addLex(LEX_REPNZ, "REPNZ"); 180 | 181 | addLex(LEX_INT, "INT"); 182 | 183 | addLex(LEX_RET, "RET"); 184 | addLex(LEX_RET, "RETN"); 185 | addLex(LEX_RETF, "RETF"); 186 | 187 | addLex(LEX_INSB, "INSB"); 188 | addLex(LEX_INSW, "INSW"); 189 | addLex(LEX_OUTSB, "OUTSB"); 190 | addLex(LEX_OUTSW, "OUTSW"); 191 | addLex(LEX_RCL1, "RCL1"); 192 | addLex(LEX_RCL, "RCL"); 193 | addLex(LEX_RCR1, "RCR1"); 194 | addLex(LEX_RCR, "RCR"); 195 | addLex(LEX_ROL1, "ROL1"); 196 | addLex(LEX_ROL, "ROL"); 197 | addLex(LEX_ROR1, "ROR1"); 198 | addLex(LEX_ROR, "ROR"); 199 | addLex(LEX_LAHF, "LAHF"); 200 | addLex(LEX_SAHF, "SAHF"); 201 | addLex(LEX_SAL1, "SAL1"); 202 | addLex(LEX_SAL, "SAL"); 203 | addLex(LEX_SAR1, "SAR1"); 204 | addLex(LEX_SAR, "SAR"); 205 | 206 | addLex(LEX_SALC, "SALC"); 207 | addLex(LEX_SBB, "SBB"); 208 | addLex(LEX_SHL1, "SHL1"); 209 | addLex(LEX_SHL, "SHL"); 210 | addLex(LEX_SHR1, "SHR1"); 211 | addLex(LEX_SHR, "SHR"); 212 | addLex(LEX_STC, "STC"); 213 | addLex(LEX_STD, "STD"); 214 | addLex(LEX_STI, "STI"); 215 | 216 | addLex(LEX_AAA, "AAA"); 217 | addLex(LEX_AAS, "AAS"); 218 | addLex(LEX_AAD, "AAD"); 219 | addLex(LEX_AAM, "AAM"); 220 | addLex(LEX_ADC, "ADC"); 221 | addLex(LEX_BOUND, "BOUND"); 222 | addLex(LEX_CLTS, "CLTS"); 223 | addLex(LEX_CMC, "CMC"); 224 | addLex(LEX_DAA, "DAA"); 225 | addLex(LEX_DAS, "DAS"); 226 | addLex(LEX_WAIT, "WAIT"); 227 | addLex(LEX_XLATB, "XLATB"); 228 | addLex(LEX_INT3, "INT3"); 229 | 230 | addLex(LEX_DB, "DB"); 231 | addLex(LEX_DW, "DW"); 232 | addLex(LEX_DD, "DD"); 233 | addLex(LEX_ORG, "ORG"); 234 | addLex(LEX_END, "END"); 235 | 236 | addLex(LEX_EXPORT, "EXPORT"); 237 | 238 | addLex(LEX_CS2DOT, "CS:"); 239 | addLex(LEX_DS2DOT, "DS:"); 240 | addLex(LEX_ES2DOT, "ES:"); 241 | addLex(LEX_SS2DOT, "SS:"); 242 | 243 | addLex(LEX_SHORT, "SHORT"); 244 | addLex(LEX_NEAR, "NEAR"); 245 | addLex(LEX_FAR, "FAR"); 246 | addLex(LEX_EQU, "EQU"); 247 | } 248 | 249 | void lex_done() { 250 | } 251 | -------------------------------------------------------------------------------- /original/src/LEX.H: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2019 DosWorld 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | Part of the MSA2 assembler 26 | 27 | */ 28 | 29 | #ifndef _LEX_H_ 30 | #define _LEX_H_ 31 | 32 | #define LEX_NONE -1 33 | 34 | #define LEX_DB 100 35 | #define LEX_DW 101 36 | #define LEX_DD 102 37 | #define LEX_EXPORT 103 38 | #define LEX_ORG 104 39 | #define LEX_EQU 105 40 | #define LEX_END 106 41 | 42 | #define LEX_SHORT 110 43 | #define LEX_NEAR 111 44 | #define LEX_FAR 112 45 | 46 | #define LEX_CS2DOT 120 47 | #define LEX_DS2DOT 121 48 | #define LEX_ES2DOT 122 49 | #define LEX_SS2DOT 123 50 | 51 | #define LEX_AAA 300 52 | #define LEX_AAS 320 53 | #define LEX_AAD 340 54 | #define LEX_AAM 360 55 | #define LEX_ADC 380 56 | #define LEX_ADD 400 57 | #define LEX_AND 420 58 | #define LEX_BOUND 440 59 | #define LEX_CALL 460 60 | #define LEX_CBW 480 61 | #define LEX_CWD 500 62 | #define LEX_CLC 520 63 | #define LEX_CLD 540 64 | #define LEX_CLI 560 65 | #define LEX_CLTS 580 66 | #define LEX_CMC 600 67 | #define LEX_CMP 620 68 | #define LEX_CMPSB 640 69 | #define LEX_CMPSW 660 70 | #define LEX_DAA 680 71 | #define LEX_DAS 700 72 | #define LEX_DEC 720 73 | #define LEX_DIV 740 74 | #define LEX_ENTER 760 75 | #define LEX_IDIV 780 76 | #define LEX_IMUL 800 77 | #define LEX_IN 820 78 | #define LEX_INC 840 79 | #define LEX_INSB 860 80 | #define LEX_INSW 880 81 | #define LEX_HALT 900 82 | #define LEX_INT3 920 83 | #define LEX_INTO 940 84 | #define LEX_IRET 960 85 | #define LEX_JCXZ 980 86 | #define LEX_JA 1000 87 | #define LEX_JAE 1020 88 | #define LEX_JB 1040 89 | #define LEX_JBE 1060 90 | #define LEX_JC 1080 91 | #define LEX_JE 1100 92 | #define LEX_JG 1120 93 | #define LEX_JGE 1140 94 | #define LEX_JL 1160 95 | #define LEX_JLE 1180 96 | #define LEX_JNA 1200 97 | #define LEX_JNAE 1220 98 | #define LEX_JNB 1240 99 | #define LEX_JNBE 1260 100 | #define LEX_JNC 1280 101 | #define LEX_JNE 1300 102 | #define LEX_JNG 1320 103 | #define LEX_JNGE 1340 104 | #define LEX_JLG 1360 105 | #define LEX_JNL 1370 106 | #define LEX_JNLE 1380 107 | #define LEX_JNO 1400 108 | #define LEX_JNP 1420 109 | #define LEX_JNS 1440 110 | #define LEX_JNZ 1460 111 | #define LEX_JO 1480 112 | #define LEX_JP 1500 113 | #define LEX_JPE 1520 114 | #define LEX_JPO 1540 115 | #define LEX_JS 1560 116 | #define LEX_JZ 1580 117 | #define LEX_LAHF 1600 118 | #define LEX_LDS 1620 119 | #define LEX_LES 1640 120 | #define LEX_LEA 1660 121 | #define LEX_LEAVE 1680 122 | #define LEX_LOOP 1740 123 | #define LEX_LOOPE 1760 124 | #define LEX_LOOPNE 1780 125 | #define LEX_LOOPZ 1800 126 | #define LEX_LOOPNZ 1820 127 | #define LEX_MOV 1840 128 | #define LEX_MOVSB 1860 129 | #define LEX_MOVSW 1880 130 | #define LEX_MUL 1900 131 | #define LEX_NEG 1920 132 | #define LEX_NOT 1940 133 | #define LEX_NOP 1960 134 | #define LEX_OR 1980 135 | #define LEX_OUT 2000 136 | #define LEX_OUTSB 2020 137 | #define LEX_OUTSW 2040 138 | #define LEX_LODSB 2060 139 | #define LEX_LODSW 2080 140 | #define LEX_POP 2100 141 | #define LEX_POPA 2120 142 | #define LEX_POPF 2140 143 | #define LEX_PUSH 2160 144 | #define LEX_PUSHA 2180 145 | #define LEX_PUSHF 2200 146 | #define LEX_REP 2220 147 | #define LEX_REPNZ 2300 148 | #define LEX_RCL1 2320 149 | #define LEX_RCL 2340 150 | #define LEX_RCR1 2360 151 | #define LEX_RCR 2380 152 | #define LEX_ROL1 2400 153 | #define LEX_ROL 2420 154 | #define LEX_ROR1 2440 155 | #define LEX_ROR 2460 156 | #define LEX_SAHF 2480 157 | #define LEX_SAL1 2500 158 | #define LEX_SAL 2520 159 | #define LEX_SAR1 2540 160 | #define LEX_SAR 2560 161 | #define LEX_RET 2580 162 | #define LEX_RETF 2600 163 | #define LEX_SALC 2620 164 | #define LEX_SBB 2640 165 | #define LEX_SCASB 2660 166 | #define LEX_SCASW 2680 167 | #define LEX_SHL1 2700 168 | #define LEX_SHL 2720 169 | #define LEX_SHR1 2740 170 | #define LEX_SHR 2760 171 | #define LEX_STC 2780 172 | #define LEX_STD 2800 173 | #define LEX_STI 2820 174 | #define LEX_STOSB 2840 175 | #define LEX_STOSW 2860 176 | #define LEX_SUB 2880 177 | #define LEX_TEST 2900 178 | #define LEX_WAIT 2920 179 | #define LEX_XCHG 2940 180 | #define LEX_XLATB 2960 181 | #define LEX_XOR 2980 182 | #define LEX_INT 3000 183 | #define LEX_JMP 3020 184 | 185 | extern int lookupLex(const char *, int *); 186 | extern void lex_init(); 187 | extern void lex_done(); 188 | 189 | #endif 190 | -------------------------------------------------------------------------------- /original/src/MAKEFILE: -------------------------------------------------------------------------------- 1 | all: msa2.exe 2 | 3 | msa2: MSA.C TABLES.C ASSEMBLR.C MISC.C LEX.C EXPR.C MSA2.H LEX.H EXPR.H 4 | gcc MSA.C TABLES.C ASSEMBLR.C LEX.C MISC.C EXPR.C -O3 -o msa2 5 | 6 | msa2w.exe: MSA.C TABLES.C ASSEMBLR.C MISC.C LEX.C EXPR.C MSA2.H LEX.H EXPR.H 7 | i686-w64-mingw32-gcc -m32 -O3 MSA.C TABLES.C ASSEMBLR.C LEX.C MISC.C EXPR.C -o MSA2W.EXE 8 | strip MSA2W.EXE 9 | 10 | msa2.exe: MSA.C TABLES.C ASSEMBLR.C MISC.C LEX.C EXPR.C MSA2.H LEX.H EXPR.H 11 | wcl MSA.C TABLES.C ASSEMBLR.C LEX.C MISC.C EXPR.C -fe=msa2.exe -mc -ox -0 12 | 13 | clean: 14 | del msa2.exe 15 | del msa2w.exe 16 | del *.obj 17 | del *.err 18 | del *.ori 19 | 20 | install: 21 | copy MSA2.EXE ..\BIN\MSA2.EXE 22 | copy MSA2W.EXE ..\BINW\MSA2W.EXE 23 | -------------------------------------------------------------------------------- /original/src/MISC.C: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2000, 2001, 2019 Robert Ostling 6 | Copyright (c) 2019 DosWorld 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | 26 | Part of the MSA2 assembler 27 | 28 | */ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include "MSA2.H" 36 | #include "EXPR.H" 37 | #include "LEX.H" 38 | 39 | int hashCode(const char *str) { 40 | int result = 0; 41 | 42 | while(*str) { 43 | result = result * 31 + *str; 44 | str++; 45 | } 46 | return result; 47 | } 48 | 49 | inline char is_numeric(char c) { 50 | return c >= '0' && c <= '9'; 51 | } 52 | 53 | inline char is_az(char c) { 54 | return c >= 'A' && c <= 'Z'; 55 | } 56 | 57 | inline char is_ident(char c) { 58 | return is_numeric(c) || is_az(c) || c == '_' || c == '$' || c == '.'; 59 | } 60 | 61 | inline char is_math(char c) { 62 | return c == '+' || c == '-' || c == '*' || c == '/' || c == '%'; 63 | } 64 | 65 | inline char is_spc(char c) { 66 | return c && (c <= ' '); 67 | } 68 | 69 | void out_msg(const char *s, int x) { 70 | if(x == 0) { 71 | errors++; 72 | } else { 73 | warnings++; 74 | } 75 | if(quiet >= x) { 76 | printf("%s:%s:%ld: %s\n", (x == 0 ? "ERROR" : "WARN"), inputname, linenr, s); 77 | } 78 | } 79 | 80 | void out_msg_str(const char *s, int x, const char *param) { 81 | sprintf(err_msg, s, param); 82 | out_msg(err_msg, x); 83 | } 84 | 85 | void out_msg_chr(const char *s, int x, char c) { 86 | sprintf(err_msg, s, c); 87 | out_msg(err_msg, x); 88 | } 89 | 90 | void out_msg_int(const char *s, int x, int i) { 91 | sprintf(err_msg, s, i); 92 | out_msg(err_msg, x); 93 | } 94 | 95 | void build_address(t_address *a) { 96 | if(a->mod == 3) { 97 | a->op_len = 1; 98 | a->op[0] = (a->mod << 6) + (a->reg << 3) + a->rm; 99 | return; 100 | } 101 | if(a->mod < 3) { 102 | a->op_len = a->mod + 1; 103 | if(a->mod == 0 && a->rm == 6) { 104 | a->op_len = 3; 105 | } 106 | } 107 | a->op[0] = (a->mod << 6) + (a->reg << 3) + a->rm; 108 | if(a->mod == 1) { 109 | a->op[1] = a->disp; 110 | } else if(a->mod == 2 || (a->mod == 0 && a->rm == 6)) { 111 | a->op[1] = (a->disp) & 0xff; 112 | a->op[2] = (a->disp >> 8) & 0xff; 113 | } 114 | } 115 | 116 | char is_reg(const char *s, const char *k, char badVal) { 117 | int i; 118 | char c1, c2, r1, r2; 119 | 120 | c1 = *s; 121 | s++; 122 | c2 = *s; 123 | s++; 124 | if(*s != 0) { 125 | return badVal; 126 | } 127 | 128 | i = 0; 129 | while((r1 = *k)) { 130 | k++; 131 | r2 = *k; 132 | k++; 133 | if((c1 == r1) && (c2 == r2)) { 134 | return i; 135 | } 136 | i++; 137 | } 138 | return badVal; 139 | } 140 | 141 | int get_type(const char* s) { 142 | char i; 143 | 144 | i = is_reg(s, "ALCLDLBLAHCHDHBHAXCXDXBXSPBPSIDIESCSSSDS", 64); 145 | if(i < 8) { 146 | return ACC_8 + i; 147 | } else if(i < 16) { 148 | return ACC_16 + i - 8; 149 | } else if(i != 64) { 150 | return SEG + i - 16; 151 | } 152 | 153 | if(s[4] == '[') { 154 | if(!memcmp(s,"BYTE[", 5)) return MEM_8; 155 | if(!memcmp(s,"WORD[", 5)) return MEM_16; 156 | } 157 | if(*s == '[') return MEM_16; 158 | return IMM; 159 | } 160 | 161 | char inline bindigit(char c) { 162 | if(c == '0' || c == '1') return c - '0'; 163 | out_msg_chr("Invalid binary digit %c", 0, c); 164 | return 0; 165 | } 166 | 167 | char inline decdigit(char c) { 168 | if(c >= '0' || c <= '9') return c - '0'; 169 | out_msg_chr("Invalid decimal digit %c", 0, c); 170 | return 0; 171 | } 172 | 173 | char inline hexdigit(char c) { 174 | if(c >= '0' && c <= '9') return c - '0'; 175 | if(c >= 'A' && c <= 'F') return c - 'A' + 10; 176 | out_msg_chr("Invalid hex digit %c", 0, c); 177 | return 0; 178 | } 179 | 180 | char inline is_hex(char c) { 181 | if(c >= '0' && c <= '9') return 1; 182 | if(c >= 'A' && c <= 'F') return 1; 183 | return 0; 184 | } 185 | 186 | char *get_dword(char *s, long int *value) { 187 | char c = s[1]; 188 | 189 | *value = 0; 190 | if(c == 'X' && *s == '0') { 191 | s += 2; 192 | while(is_hex(c = *s)) { 193 | *value = ((*value) << 4) | hexdigit(c); 194 | s++; 195 | } 196 | } else if(c == 'B' && *s == '0') { 197 | s += 2; 198 | c = *s; 199 | while(c == '0' || c == '1') { 200 | *value = ((*value) << 1) | (c - '0'); 201 | s++; 202 | c = *s; 203 | } 204 | } else { 205 | c = *s; 206 | while(c >= '0' && c <= '9') { 207 | *value = ((*value) * 10) + (c - '0'); 208 | s++; 209 | c = *s; 210 | } 211 | } 212 | return s; 213 | } 214 | 215 | int get_number(char* s) { 216 | char c1, c2; 217 | int value = 0; 218 | 219 | c1 = s[0]; 220 | c2 = s[1]; 221 | if(c1 == '0') { 222 | if(c2 == 'X') { 223 | s += 2; 224 | while((c1 = *s)) { 225 | value = (value << 4) | hexdigit(c1); 226 | s++; 227 | } 228 | return value; 229 | } else if(c2 == 'B') { 230 | s += 2; 231 | while((c1 = *s)) { 232 | value = (value << 1) | bindigit(c1); 233 | s++; 234 | } 235 | return value; 236 | } 237 | } 238 | while((c1 = *s)) { 239 | value = (value * 10) + decdigit(c1); 240 | s++; 241 | } 242 | return value; 243 | } 244 | 245 | int get_const(const char* s) { 246 | int j; 247 | char tmp[32], sign; 248 | int value, x; 249 | t_constant *c; 250 | 251 | value = 0; 252 | 253 | while(*s) { 254 | if(is_math(sign = *s)) { 255 | s++; 256 | } else { 257 | sign = '+'; 258 | } 259 | if(*s == '\'') { 260 | s++; 261 | x = *s; 262 | s++; 263 | s++; 264 | } else { 265 | j = 0; 266 | while(is_ident(*s)) { 267 | tmp[j] = *s; 268 | j++; 269 | s++; 270 | } 271 | tmp[j] = 0; 272 | x = 0; 273 | if(is_numeric(tmp[0])) { 274 | x = get_number(tmp); 275 | } else { 276 | if((c = find_const(tmp)) != NULL) { 277 | x = c->value; 278 | } else { 279 | if(pass) { 280 | out_msg_str("Undefined constant '%s'", 1, tmp); 281 | } 282 | return 0x00; 283 | } 284 | } 285 | } 286 | switch(sign) { 287 | case '+': 288 | value += x; 289 | break; 290 | case '-': 291 | value -= x; 292 | break; 293 | case '*': 294 | value *= x; 295 | break; 296 | case '/': 297 | value /= x; 298 | break; 299 | case '%': 300 | value = value % x; 301 | break; 302 | default: 303 | out_msg_chr("Unknown math operation '%c'", 0, sign); 304 | break; 305 | } 306 | } 307 | 308 | return value; 309 | } 310 | 311 | inline char *skip_until(char *s, char c) { 312 | while((*s != c) && *s) { 313 | s++; 314 | } 315 | if(*s) { 316 | s++; 317 | } 318 | return s; 319 | } 320 | 321 | int get_address(t_address* a, char* s) { 322 | int i = 0, k; 323 | char c1, j1, j2; 324 | byte seg_pre; 325 | 326 | i = is_reg(s, "ALCLDLBLAHCHDHBHAXCXDXBXSPBPSIDI", 255); 327 | 328 | if(i < 16) { 329 | a->rm = i < 8 ? i : i - 8; 330 | a->mod = 3; 331 | return 0; 332 | } 333 | 334 | s = skip_until(s, '['); 335 | 336 | if(*s == 0) { 337 | return 1; 338 | } 339 | i = 0; 340 | 341 | if(s[2] == ':') { 342 | c1 = *s; 343 | if(s[1] != 'S') { 344 | out_msg("Syntax error in segment register name", 0); 345 | seg_pre = 0x90; 346 | } else if(c1 == 'C') { 347 | seg_pre = 0x2e; 348 | } else if(c1 == 'D') { 349 | seg_pre = 0x3e; 350 | } else if(c1 == 'E') { 351 | seg_pre = 0x26; 352 | } else if(c1 == 'S') { 353 | seg_pre = 0x36; 354 | } else { 355 | out_msg("Syntax error in segment register name", 0); 356 | seg_pre = 0x90; 357 | } 358 | 359 | for(k = old_outptr + 4; k > old_outptr; k--) { 360 | outprog[k] = outprog[k-1]; 361 | } 362 | s += 3; 363 | outprog[old_outptr] = seg_pre; 364 | outptr++; 365 | } 366 | c1 = s[2] == '+'; 367 | j1 = *s; 368 | j2 = *(s + 1); 369 | if(c1 && !memcmp(s, "BX+SI", 5)) { 370 | a->rm = 0; 371 | s += 5; 372 | } else if(c1 && !memcmp(s, "BX+DI", 5)) { 373 | a->rm = 1; 374 | s += 5; 375 | } else if(c1 && !memcmp(s, "BP+SI", 5)) { 376 | a->rm = 2; 377 | s += 5; 378 | } else if(c1 && !memcmp(s, "BP+DI", 5)) { 379 | a->rm = 3; 380 | s += 5; 381 | } else if(j1 == 'S' && j2 == 'I') { 382 | a->rm = 4; 383 | s += 2; 384 | } else if(j1 == 'D' && j2 == 'I') { 385 | a->rm = 5; 386 | s += 2; 387 | } else if(j1 == 'B' && j2 == 'P') { 388 | a->rm = 6; 389 | s += 2; 390 | } else if(j1 == 'B' && j2 == 'X') { 391 | a->rm = 7; 392 | s += 2; 393 | } else { 394 | a->mod = 0; 395 | a->rm = 6; 396 | s[strlen(s) - 1] = 0; 397 | a->disp = get_const(s); 398 | return 0; 399 | } 400 | 401 | if(is_math(*s)) { 402 | s[strlen(s) - 1] = 0; 403 | a->disp = get_const(s); 404 | // HERE ?? 405 | a->mod = a->disp < 0x80 ? 1 : 2; 406 | } else { 407 | a->mod = 0; 408 | } 409 | 410 | if((a->rm == 6) && (a->mod == 0)) { 411 | a->disp = 0; 412 | a->mod = 1; 413 | } 414 | 415 | return 0; 416 | } 417 | 418 | void *msa_malloc(size_t s) { 419 | void *r; 420 | if((r = malloc(s)) == NULL) { 421 | out_msg("Could not allocate memory", 0); 422 | done(4); 423 | } 424 | return r; 425 | } 426 | 427 | char *get_param(char *dest, char *line) { 428 | char c; 429 | while((c = *line)) { 430 | if(c == ',') { 431 | break; 432 | } else if(c == ' ') { 433 | line++; 434 | } else if(c == '\'' || c == '"') { 435 | *dest = c; 436 | dest++; 437 | line++; 438 | while((*line) && (*line != c)) { 439 | *dest = *line; 440 | dest++; 441 | line++; 442 | } 443 | if(*line) { 444 | *dest = *line; 445 | dest++; 446 | line++; 447 | } 448 | } else { 449 | *dest = c; 450 | dest++; 451 | line++; 452 | } 453 | } 454 | *dest = 0; 455 | return line; 456 | } 457 | 458 | void split_line(t_line *cur, char *line, char *a1) { 459 | char *p, *p2, c, c1, c2, c3, c4, c5; 460 | char full_param; 461 | p = line; 462 | p2 = a1; 463 | 464 | cur->p1[0] = 0; 465 | cur->p2[0] = 0; 466 | full_param = 0; 467 | cur->lex2 = LEX_NONE; 468 | while((c = *p)) { 469 | if((c == ' ') || (c == ':')) { 470 | break; 471 | } 472 | *p2 = c; 473 | p++; 474 | p2++; 475 | } 476 | *p2 = 0; 477 | while((c = *p) && (c == ' ')) { 478 | p++; 479 | } 480 | if(c == ':') { 481 | strcpy(cur->label, a1); 482 | cur->has_label = 1; 483 | line = p + 1; 484 | } else { 485 | c1 = *p; 486 | c2 = *(p+1); 487 | c3 = *(p+2); 488 | c4 = *(p+3); 489 | if(c1 == 'E' && c2 == 'Q' && c3 == 'U' && c4 == ' ') { 490 | strcpy(cur->label, a1); 491 | full_param = 1; 492 | line = p; 493 | } 494 | } 495 | if(!*line) { 496 | return; 497 | } 498 | while((c = *line) && (c == ' ')) { 499 | line++; 500 | } 501 | 502 | c1 = line[0]; 503 | c2 = line[1]; 504 | c3 = line[2]; 505 | c4 = line[3]; 506 | c5 = line[4]; 507 | 508 | if((c1 == 'L' && c2 == 'O' && c3 == 'C' && c4 == 'K' && c5 == ' ')) { 509 | cur->has_lock = 1; 510 | line += 5; 511 | } 512 | 513 | c1 = line[0]; 514 | c2 = line[1]; 515 | c3 = line[2]; 516 | c4 = line[3]; 517 | c5 = line[4]; 518 | 519 | if((c1 == 'R' && c2 == 'E' && c3 == 'P')) { 520 | if(c4 == ' ') { 521 | cur->rep_type = LEX_REP; 522 | line += 4; 523 | } else if((c4 == 'Z' || c4 == 'E') && c5 == ' ') { 524 | cur->rep_type = LEX_REP; 525 | line += 5; 526 | } else if((c4 == 'N') && (c5 == 'Z' || c5 == 'E')) { 527 | cur->rep_type = LEX_REPNZ; 528 | line += 6; 529 | } 530 | } 531 | 532 | p = cur->cmd; 533 | while((c = toupper(*line)) && (c > ' ')) { 534 | *p = c; 535 | line++; 536 | p++; 537 | } 538 | 539 | *p = 0; 540 | 541 | while((c = *line) && (c == ' ')) { 542 | line++; 543 | } 544 | 545 | if(!*line) { 546 | return; 547 | } 548 | 549 | if(!full_param) { 550 | c1 = cur->cmd[0]; 551 | c2 = cur->cmd[1]; 552 | c3 = cur->cmd[2]; 553 | if((c3 == 0) && (c1 == 'R' || c1 == 'D')) { 554 | if(c2 == 'B' || c2 == 'W' || c3 == 'D') { 555 | full_param = 1; 556 | } 557 | } 558 | } 559 | 560 | if(full_param) { 561 | p = cur->p1; 562 | while((c = *line)) { 563 | if(c == ' ') { 564 | line++; 565 | } else if(c == '\'' || c == '"') { 566 | *p = c; 567 | p++; 568 | line++; 569 | while((*line) && (*line != c)) { 570 | *p = *line; 571 | p++; 572 | line++; 573 | } 574 | if(*line) { 575 | *p = *line; 576 | p++; 577 | line++; 578 | } 579 | } else { 580 | *p = c; 581 | p++; 582 | line++; 583 | } 584 | } 585 | *p = 0; 586 | cur->pcount = 1; 587 | return; 588 | } 589 | if(!memcmp(line, "SHORT ", 6)) { 590 | cur->lex2 = LEX_SHORT; 591 | line += 6; 592 | } else if(!memcmp(line, "NEAR ", 5)) { 593 | cur->lex2 = LEX_NEAR; 594 | line += 5; 595 | } else if(!memcmp(line, "FAR ", 4)) { 596 | cur->lex2 = LEX_FAR; 597 | line += 4; 598 | } 599 | 600 | line = get_param(a1, line); 601 | if(*a1 != 0) { 602 | strcpy(cur->p1, a1); 603 | cur->pcount++; 604 | } 605 | if(*line == ',') { 606 | line++; 607 | line = get_param(a1, line); 608 | strcpy(cur->p2, a1); 609 | cur->pcount++; 610 | } 611 | } 612 | 613 | char strip_line(char *line) { 614 | char *line_b, *line_e, *p, *p2, c; 615 | int error = 0; 616 | 617 | line_b = line; 618 | while(is_spc(*line_b)) { 619 | line_b++; 620 | } 621 | line_e = line_b; 622 | while((c = *line_e) && !error) { 623 | if(c == '\'' || c == '"') { 624 | line_e++; 625 | line_e = skip_until(line_e, c); 626 | if(!*line_e) { 627 | error = 1; 628 | } 629 | } else if(c < ' ') { 630 | *line_e = ' '; 631 | } else if(c == ';') { 632 | *line_e = 0; 633 | break; 634 | } else { 635 | line_e++; 636 | } 637 | } 638 | if(error) { 639 | return 0; 640 | } 641 | p = line_b - 1; 642 | while(p != line_e) { 643 | if(*line_e > ' ') { 644 | break; 645 | } 646 | *line_e = 0; 647 | line_e--; 648 | } 649 | p = line; 650 | p2 = line_b; 651 | while((c = *p2)) { 652 | if(c == '"' || c == '\'') { 653 | *p = *p2; 654 | p++; 655 | p2++; 656 | while((*p2) && (*p2 != c)) { 657 | *p = *p2; 658 | p++; 659 | p2++; 660 | } 661 | if(*p2) { 662 | *p = *p2; 663 | p++; 664 | p2++; 665 | } 666 | } else if(c == ' ') { 667 | *p = *p2; 668 | p++; 669 | p2++; 670 | while((c = *p2) && (c == ' ')) { 671 | p2++; 672 | } 673 | } else { 674 | *p = toupper(*p2); 675 | p++; 676 | p2++; 677 | } 678 | } 679 | *p = 0; 680 | return 1; 681 | } 682 | -------------------------------------------------------------------------------- /original/src/MSA.C: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2000, 2001, 2019 Robert Ostling 6 | Copyright (c) 2019 DosWorld 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | 26 | Part of the MSA2 assembler 27 | 28 | */ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include "MSA2.H" 36 | #include "EXPR.H" 37 | #include "LEX.H" 38 | 39 | unsigned char ovlboot[] = { 0x0E, 0x1F, 0xBA, 0x0D, 0x00, 0xB4, 0x09, 0xCD, 0x21, 0xB4, 0x4C, 0xCD, 0x21, 0x54, 0x68, 0x69, 40 | 0x73, 0x20, 0x69, 0x73, 0x20, 0x6F, 0x76, 0x65, 0x72, 0x6C, 0x61, 0x79, 0x20, 0x66, 0x69, 0x6C, 41 | 0x65, 0x2E, 0x0D, 0x0A, 0x24 42 | }; 43 | 44 | char err_msg[512]; 45 | char outname[256]; 46 | char *inputname = NULL; 47 | FILE* outfile; 48 | int target; 49 | byte* outprog; 50 | word outptr; 51 | 52 | int errors, warnings; 53 | 54 | byte quiet = 1; 55 | 56 | int pass; 57 | int passes = 2; 58 | 59 | word org = 0x0100; 60 | char is_org_def; 61 | 62 | word code_size; 63 | word bss_size; 64 | word entry_point; 65 | char entry_point_def = 0; 66 | 67 | char write_ovl_boot() { 68 | size_t i; 69 | 70 | if(target != TARGET_OVL) { 71 | return 1; 72 | } 73 | 74 | for(i = 0; i < sizeof(ovlboot); i++) { 75 | outprog[outptr++] = ovlboot[i]; 76 | } 77 | 78 | return 1; 79 | } 80 | 81 | void recalc_bss_labels(int code_size) { 82 | t_constant *c; 83 | 84 | c = constants; 85 | while(c != NULL) { 86 | if(CONST_TYPE(c) == CONST_BSS) { 87 | c->value += code_size; 88 | } 89 | c = (t_constant *)c->next; 90 | } 91 | } 92 | 93 | char write_ovl_exports(FILE *o) { 94 | word magik, count; 95 | t_constant *c; 96 | t_ovl_export e; 97 | 98 | if((target != TARGET_OVL && target != TARGET_TEXE) || !pass) { 99 | return 1; 100 | } 101 | 102 | magik = OVL_SYMTAB_MAGIK; 103 | 104 | count = 0; 105 | 106 | c = constants; 107 | while(c != NULL) { 108 | if(c->is_export) { 109 | count++; 110 | } 111 | c = (t_constant *)c->next; 112 | } 113 | 114 | fwrite(&magik, 1, sizeof(magik), o); 115 | fwrite(&count, 1, sizeof(count), o); 116 | count *= sizeof(t_ovl_export); 117 | fwrite(&count, 1, sizeof(count), o); 118 | 119 | c = constants; 120 | while(c != NULL) { 121 | if(c->is_export) { 122 | strncpy(e.name, c->name, EXPORT_NAME_LENGTH); 123 | e.flags = 0; 124 | e.ofs = c->value; 125 | fwrite(&e, 1, sizeof(e), o); 126 | } 127 | c = (t_constant *)c->next; 128 | } 129 | return 1; 130 | } 131 | 132 | void check_entry_point() { 133 | if(!pass) { 134 | return; 135 | } 136 | switch(target) { 137 | case TARGET_BIN: 138 | break; 139 | case TARGET_COM: 140 | if(entry_point != 0x0100) { 141 | out_msg_int("Invalid entry point 0x%04X for .COM-file.", 0, entry_point); 142 | } 143 | break; 144 | case TARGET_OVL: 145 | if(entry_point != 0 || entry_point_def) { 146 | out_msg("Overlay can't have entry point", 0); 147 | } 148 | break; 149 | case TARGET_TEXE: 150 | if(!entry_point_def) { 151 | out_msg("No entry point for .exe file", 0); 152 | } 153 | break; 154 | } 155 | } 156 | 157 | char write_exe_header(FILE *o, word entry_point, word image_size, word bss_size) { 158 | word exe_hdr[0x10]; 159 | word bss_par; 160 | word block_count; 161 | word inlastblock; 162 | 163 | if(target != TARGET_OVL && target != TARGET_TEXE) { 164 | return 1; 165 | } 166 | 167 | bss_par = (bss_size >> 4) + (bss_size & 0x0f ? 1 : 0); 168 | 169 | if(target == TARGET_TEXE) { 170 | bss_par = 0xffff - (image_size + bss_size); 171 | bss_par = (bss_par >> 4) + (bss_par & 0x0f ? 1 : 0); 172 | } 173 | // bss_par &= 0x0fff; 174 | 175 | inlastblock = image_size % 512; 176 | block_count = image_size / 512; 177 | if(inlastblock) { 178 | block_count++; 179 | } 180 | 181 | memset(exe_hdr, 0, sizeof(exe_hdr)); 182 | exe_hdr[0x00] = 0x5a4d; 183 | exe_hdr[0x01] = inlastblock; 184 | exe_hdr[0x02] = block_count; 185 | exe_hdr[0x04] = 2; 186 | exe_hdr[0x05] = bss_par; 187 | exe_hdr[0x06] = bss_par; 188 | exe_hdr[0x08] = 0xfffe; /* Default SP */ 189 | exe_hdr[0x0a] = entry_point; /* Entry point IP */ 190 | 191 | return fwrite(exe_hdr, 1, sizeof(exe_hdr), o) == sizeof(exe_hdr); 192 | } 193 | 194 | void done(int code) { 195 | 196 | lex_done(); 197 | if(code != 0) { 198 | remove(outname); 199 | } 200 | 201 | free(outprog); 202 | expr_done(); 203 | exit(code); 204 | } 205 | 206 | void help(int code) { 207 | printf("%s assembler Version %d.%d (build %d)\nCopyright(C) 2000, 2001, 2019 Robert Ostling\nCopyright(C) 2019 DosWorld\nMIT License https://opensource.org/licenses/MIT\n\n",PROG_NAME,MAIN_VERSION,SUB_VERSION,BUILD); 208 | printf("%s file.asm -ofile.com [-options]\n\n" 209 | "options:\n" 210 | "\t-s xxxx set starting point to xxxx (default 0x100)\n" 211 | "\t-m x set error/waning level (default 2)\n" 212 | "\t-f xxx set output format bin, com, texe, ovl (default com)\n" 213 | "\t-dCONST=VAL set assign VAL to CONST\n\n" 214 | "Error/Warning levels:\n\n" 215 | "\t0\tErrors only\n" 216 | "\t1\tErrors and serious warnings\n" 217 | "\t2\tAll\n\n", PROG_NAME); 218 | done(code); 219 | } 220 | 221 | int main(int argc, char* argv[]) { 222 | int i, j, assembleResult; 223 | char c, *p; 224 | char tmp[256]; 225 | 226 | if(argc < 2) { 227 | help(1); 228 | } 229 | 230 | expr_init(); 231 | 232 | target = TARGET_UNDEF; 233 | outname[0] = 0; 234 | linenr = 0; 235 | outprog = (byte *)MSA_MALLOC(65000); 236 | outptr = org = 0; 237 | is_org_def = 0; 238 | 239 | for(i = 1; i < argc; i++) { 240 | c = argv[i][0]; 241 | if((c == '-' || c == '/') && (i + 1 < argc)) { 242 | switch(toupper(argv[i][1])) { 243 | case 'F': 244 | if(!strcasecmp(argv[i + 1],"bin")) { 245 | target = TARGET_BIN; 246 | i++; 247 | } else if(!strcasecmp(argv[i + 1],"com")) { 248 | target = TARGET_COM; 249 | entry_point = outptr = org = 0x100; 250 | entry_point_def = 1; 251 | is_org_def = 1; 252 | i++; 253 | } else if(!strcasecmp(argv[i + 1],"texe")) { 254 | target = TARGET_TEXE; 255 | entry_point = outptr = org = 0; 256 | entry_point_def = 0; 257 | is_org_def = 1; 258 | i++; 259 | } else if(!strcasecmp(argv[i + 1],"ovl")) { 260 | target = TARGET_OVL; 261 | entry_point = outptr = org = 0; 262 | entry_point_def = 0; 263 | org = 0; 264 | is_org_def = 1; 265 | i++; 266 | } else { 267 | help(1); 268 | } 269 | break; 270 | case 'O': 271 | strcpy(outname, argv[i + 1]); 272 | i++; 273 | break; 274 | case 'S': 275 | org = get_const(argv[i + 1]); 276 | i++; 277 | break; 278 | case 'M': 279 | quiet = get_const(argv[i + 1]); 280 | i++; 281 | break; 282 | default: 283 | help(1); 284 | } 285 | } else if((c == '-' || c == '/')) { 286 | switch(toupper(argv[i][1])) { 287 | case 'D': 288 | p = argv[i] + 2; 289 | j = 0; 290 | while((*p) && (*p != '=') && (j < (sizeof(tmp) - 1))) { 291 | tmp[j] = *p; 292 | p++; 293 | j++; 294 | } 295 | tmp[j] = 0; 296 | if(*p != '=') help(1); 297 | strupr(tmp); 298 | add_const(tmp, CONST_EXPR, get_const(p)); 299 | break; 300 | default: 301 | help(1); 302 | } 303 | } else { 304 | if(inputname != NULL) { 305 | help(1); 306 | } 307 | inputname = argv[i]; 308 | } 309 | } 310 | 311 | if(outname[0] == 0) { 312 | out_msg("No output file.", 0); 313 | done(1); 314 | } 315 | 316 | if(target == TARGET_UNDEF) { 317 | target = TARGET_COM; 318 | outptr = org = 0x100; 319 | entry_point = 0x100; 320 | entry_point_def = 1; 321 | is_org_def = 1; 322 | } 323 | 324 | switch(target) { 325 | case TARGET_COM: 326 | outptr = org = 0x0100; 327 | break; 328 | case TARGET_TEXE: 329 | outptr = org = 0; 330 | case TARGET_OVL: 331 | outptr = org = 0x0000; 332 | break; 333 | } 334 | 335 | lex_init(); 336 | bss_size = 0; 337 | assembleResult = 1; 338 | code_size = 0; 339 | 340 | add_const("$", CONST_EXPR, outptr); 341 | add_const("$$", CONST_EXPR, org); 342 | 343 | for(pass = 0; pass < passes && assembleResult; pass++) { 344 | if((outfile = fopen(outname,"wb"))==0) { 345 | out_msg("Can't open output file.", 0); 346 | done(2); 347 | } 348 | check_entry_point(); 349 | write_exe_header(outfile, entry_point, code_size, bss_size); 350 | outptr = org; 351 | errors = 0; 352 | warnings = 0; 353 | write_ovl_boot(); 354 | assembleResult = assemble(inputname); 355 | code_size = outptr - org; 356 | fwrite(outprog + org, 1, code_size, outfile); 357 | if(!pass) { 358 | recalc_bss_labels(code_size); 359 | } 360 | write_ovl_exports(outfile); 361 | fseek(outfile, 0, SEEK_SET); 362 | write_exe_header(outfile, entry_point, code_size, bss_size); 363 | fclose(outfile); 364 | } 365 | 366 | if(errors > 0) { 367 | done(2); 368 | } else if(warnings > 0) { 369 | done(1); 370 | } 371 | done(0); 372 | return 0; 373 | } 374 | -------------------------------------------------------------------------------- /original/src/MSA2.H: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2000, 2001, 2019 Robert Ostling 6 | Copyright (c) 2019 DosWorld 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | 26 | Part of the MSA2 assembler 27 | 28 | */ 29 | 30 | #ifndef _MSA2_H_ 31 | #define _MSA2_H_ 32 | 33 | #define MAIN_VERSION 1 34 | #define SUB_VERSION 0 35 | #define BUILD 14 36 | #define PROG_NAME "MSA2" 37 | 38 | #define MAX_LABEL 32 39 | 40 | #define TARGET_UNDEF 0 41 | #define TARGET_BIN 1 42 | #define TARGET_COM 2 43 | #define TARGET_TEXE 3 44 | #define TARGET_OVL 100 45 | 46 | #define EXPORT_NAME_LENGTH 32 47 | 48 | #define MSA_MALLOC(x) msa_malloc(x) 49 | 50 | typedef uint8_t byte; 51 | typedef uint16_t word; 52 | typedef uint32_t dword; 53 | 54 | #define IMM 0X00 55 | #define REG_8 0X01 56 | #define REG_16 0X02 57 | #define REG_SEG 0X03 58 | #define MEM_8 0X04 59 | #define MEM_16 0X05 60 | #define RM_8 0X06 61 | #define RM_16 0X07 62 | #define ACC_8 0X10 63 | #define AL 0X10 64 | #define CL 0X11 65 | #define DL 0X12 66 | #define BL 0X13 67 | #define AH 0X14 68 | #define CH 0X15 69 | #define DH 0X16 70 | #define BH 0X17 71 | #define ACC_16 0X20 72 | #define AX 0X20 73 | #define CX 0X21 74 | #define DX 0X22 75 | #define BX 0X23 76 | #define SP 0X24 77 | #define BP 0X25 78 | #define SI 0X26 79 | #define DI 0X27 80 | #define SEG 0X30 81 | #define ES 0X30 82 | #define CS 0X31 83 | #define SS 0X32 84 | #define DS 0X33 85 | 86 | #define OP_CMD_OP 0X01 87 | #define OP_CMD_IMM8 0X02 88 | #define OP_CMD_IMM16 0X03 89 | #define OP_CMD_PLUSREG8 0X04 90 | #define OP_CMD_PLUSREG16 0X05 91 | #define OP_CMD_PLUSREGSEG 0X06 92 | #define OP_CMD_RM1_8 0X07 93 | #define OP_CMD_RM1_16 0X08 94 | #define OP_CMD_RM2_8 0X09 95 | #define OP_CMD_RM2_16 0X0A 96 | #define OP_CMD_RMLINE_8 0X0B 97 | #define OP_CMD_RMLINE_16 0X0C 98 | #define OP_CMD_REL8 0X0D 99 | #define OP_CMD_REL16 0X0E 100 | #define OP_CMD_RM1_SEG 0X0F 101 | #define OP_CMD_RM2_SEG 0X10 102 | 103 | #define OVL_SYMTAB_MAGIK 0xFE33 104 | 105 | #define CONST_LABEL 1 106 | #define CONST_EXPR 2 107 | #define CONST_BSS 3 108 | #define CONST_UNDEF 0x80 109 | 110 | #define IS_CONST_UNDEF(x) (((x)->type & CONST_UNDEF) != 0) 111 | #define IS_CONST_DEF(x) (((x)->type & CONST_UNDEF) == 0) 112 | #define CONST_TYPE(x) ((x)->type & 0x7f) 113 | 114 | typedef struct { 115 | byte mod; 116 | byte reg; 117 | byte rm; 118 | int disp; 119 | byte op_len; 120 | byte op[0x06]; 121 | } t_address; 122 | 123 | typedef struct { 124 | char name[64]; 125 | char is_export; 126 | int hash; 127 | char type; 128 | int value; 129 | void *next; 130 | } t_constant; 131 | 132 | typedef struct { 133 | int lex1, lex2; 134 | int params; 135 | int param_type[4]; 136 | int op[10]; 137 | } t_instruction; 138 | 139 | typedef struct { 140 | dword lnum; 141 | char has_label; 142 | char pcount; 143 | char has_lock; 144 | int rep_type; 145 | int lex2; 146 | char label[MAX_LABEL]; 147 | char cmd[16]; 148 | char p1[4096]; 149 | char p2[4096]; 150 | } t_line; 151 | 152 | #pragma pack(push) 153 | #pragma pack(1) 154 | typedef struct { 155 | char name[EXPORT_NAME_LENGTH]; 156 | word ofs; 157 | word flags; 158 | } t_ovl_export; 159 | #pragma pack(pop) 160 | 161 | extern t_instruction instr86[]; 162 | 163 | extern int assemble(char* fname); 164 | 165 | extern void out_msg(const char *s, int x); 166 | extern void out_msg_str(const char *s, int x, const char *param); 167 | extern void out_msg_chr(const char *s, int x, char c); 168 | extern void out_msg_int(const char *s, int x, int i); 169 | 170 | extern void build_address(t_address* a); 171 | 172 | extern int get_type(const char* s); 173 | extern int hashCode(const char *str); 174 | extern int get_number(char* s); 175 | extern int get_address(t_address* a, char* s); 176 | extern void get_line(char* s); 177 | extern void split(char* s); 178 | 179 | extern char err_msg[]; 180 | extern int errors, warnings, pass, passes, params; 181 | extern word outptr; 182 | extern byte quiet; 183 | extern byte *outprog; 184 | extern word org; 185 | extern char is_org_def; 186 | extern FILE *outfile; 187 | extern long int linenr; 188 | extern char *param[2]; 189 | extern int param_type[2]; 190 | extern word old_outptr; 191 | extern word ptr; 192 | 193 | extern int get_const(const char *s); 194 | extern char *get_dword(char *s, long int *x); 195 | 196 | extern word entry_point; 197 | extern char entry_point_def; 198 | extern char *inputname; 199 | 200 | extern char strip_line(char *line); 201 | extern void split_line(t_line *cur, char *line, char *a1); 202 | 203 | extern void *msa_malloc(size_t size); 204 | extern void done(int c); 205 | 206 | #endif 207 | -------------------------------------------------------------------------------- /original/src/TABLES.C: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2000, 2001, 2019 Robert Ostling 6 | Copyright (c) 2019 DosWorld 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | 26 | Part of the MSA2 assembler 27 | 28 | */ 29 | 30 | #include 31 | #include 32 | #include 33 | #include "MSA2.H" 34 | #include "LEX.H" 35 | 36 | t_instruction instr86[] = { 37 | { LEX_AAS, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0x3f,0,0,0,0,0,0,0,0 }, 38 | { LEX_AAD, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xd5,OP_CMD_OP,0x0a,0,0,0,0,0,0 }, 39 | { LEX_AAD, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0xd5,OP_CMD_IMM8,0,0,0,0,0,0,0 }, 40 | { LEX_AAM, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xd4,OP_CMD_OP,0x0a,0,0,0,0,0,0 }, 41 | { LEX_AAM, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0xd4,OP_CMD_IMM8,0,0,0,0,0,0,0 }, 42 | { LEX_ADC, LEX_NONE, 2,ACC_8,IMM,0,0,OP_CMD_OP,0x14,OP_CMD_IMM8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OP,0x00,OP_CMD_RM2_8,1,0,0,0,0,0,0}, 56 | { LEX_ADD, LEX_NONE, 2,RM_16,REG_16,0,0,OP_CMD_OP,0x01,OP_CMD_RM2_16,1,0,0,0,0,0,0}, 57 | { LEX_ADD, LEX_NONE, 2,RM_8,IMM,0,0,OP_CMD_OP,0x80,OP_CMD_RMLINE_8,0,0,OP_CMD_IMM8,1,0,0,0}, 58 | { LEX_ADD, LEX_NONE, 2,RM_16,IMM,0,0,OP_CMD_OP,0x81,OP_CMD_RMLINE_16,0,0,OP_CMD_IMM16,1,0,0,0}, 59 | { LEX_AND, LEX_NONE, 2,ACC_8,IMM,0,0,OP_CMD_OP,0x24,OP_CMD_IMM8,1,0,0,0,0,0,0}, 60 | { LEX_AND, LEX_NONE, 2,ACC_16,IMM,0,0,OP_CMD_OP,0x25,OP_CMD_IMM16,1,0,0,0,0,0,0}, 61 | { LEX_AND, LEX_NONE, 2,REG_8,RM_8,0,0,OP_CMD_OP,0x22,OP_CMD_RM1_8,1,0,0,0,0,0,0}, 62 | { LEX_AND, LEX_NONE, 2,REG_16,RM_16,0,0,OP_CMD_OP,0x23,OP_CMD_RM1_16,1,0,0,0,0,0,0}, 63 | { LEX_AND, LEX_NONE, 2,RM_8,REG_8,0,0,OP_CMD_OP,0x20,OP_CMD_RM2_8,1,0,0,0,0,0,0}, 64 | { LEX_AND, LEX_NONE, 2,RM_16,REG_16,0,0,OP_CMD_OP,0x21,OP_CMD_RM2_16,1,0,0,0,0,0,0}, 65 | { LEX_AND, LEX_NONE, 2,RM_8,IMM,0,0,OP_CMD_OP,0x80,OP_CMD_RMLINE_8,4,0,OP_CMD_IMM8,1,0,0,0}, 66 | { LEX_AND, LEX_NONE, 2,RM_16,IMM,0,0,OP_CMD_OP,0x81,OP_CMD_RMLINE_16,4,0,OP_CMD_IMM16,1,0,0,0}, 67 | { LEX_BOUND, LEX_NONE, 2,REG_16,MEM_16,0,0,OP_CMD_OP,0x62,OP_CMD_RM2_16,1,0,0,0,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0,OP_CMD_OP,0xf7,OP_CMD_RMLINE_16,6,0,0,0,0,0,0}, 96 | { LEX_ENTER, LEX_NONE, 2,IMM,IMM,0,0,OP_CMD_OP,0xc8,OP_CMD_IMM16,0,OP_CMD_IMM8,1,0,0,0,0}, 97 | { LEX_IDIV, LEX_NONE, 1,RM_8,0,0,0,OP_CMD_OP,0xf6,OP_CMD_RMLINE_8,7,0,0,0,0,0,0}, 98 | { LEX_IDIV, LEX_NONE, 1,RM_16,0,0,0,OP_CMD_OP,0xf7,OP_CMD_RMLINE_16,7,0,0,0,0,0,0}, 99 | { LEX_IMUL, LEX_NONE, 1,RM_8,0,0,0,OP_CMD_OP,0xf6,OP_CMD_RMLINE_8,5,0,0,0,0,0,0}, 100 | { LEX_IMUL, LEX_NONE, 1,RM_16,0,0,0,OP_CMD_OP,0xf7,OP_CMD_RMLINE_16,5,0,0,0,0,0,0}, 101 | { LEX_IN, LEX_NONE, 2,ACC_8,IMM,0,0,OP_CMD_OP,0xe4,OP_CMD_IMM8,1,0,0,0,0,0,0}, 102 | { LEX_IN, LEX_NONE, 2,ACC_16,IMM,0,0,OP_CMD_OP,0xe5,OP_CMD_IMM8,1,0,0,0,0,0,0}, 103 | { LEX_IN, LEX_NONE, 2,ACC_8,DX,0,0,OP_CMD_OP,0xec,0,0,0,0,0,0,0,0}, 104 | { LEX_IN, LEX_NONE, 2,ACC_16,DX,0,0,OP_CMD_OP,0xed,0,0,0,0,0,0,0,0}, 105 | { LEX_INC, LEX_NONE, 1,REG_16,0,0,0,OP_CMD_PLUSREG16,0x40,0,0,0,0,0,0,0,0}, 106 | { LEX_INC, LEX_NONE, 1,RM_8,0,0,0,OP_CMD_OP,0xfe,OP_CMD_RMLINE_8,0,0,0,0,0,0,0}, 107 | { LEX_INC, LEX_NONE, 1,RM_16,0,0,0,OP_CMD_OP,0xff,OP_CMD_RMLINE_16,0,0,0,0,0,0,0}, 108 | { LEX_INSB, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0x6c,0,0,0,0,0,0,0,0}, 109 | { LEX_INSW, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0x6d,0,0,0,0,0,0,0,0}, 110 | { LEX_HALT, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xf4,0,0,0,0,0,0,0,0}, 111 | { LEX_INT3, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xcc,0,0,0,0,0,0,0,0}, 112 | { LEX_INTO, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xce,0,0,0,0,0,0,0,0}, 113 | { LEX_IRET, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xcf,0,0,0,0,0,0,0,0}, 114 | { LEX_JCXZ, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0xe3,OP_CMD_REL8,0,0,0,0,0,0,0}, 115 | { LEX_JA, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0x77,OP_CMD_REL8,0,0,0,0,0,0,0}, 116 | { LEX_JAE, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0x73,OP_CMD_REL8,0,0,0,0,0,0,0}, 117 | { LEX_JB, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0x72,OP_CMD_REL8,0,0,0,0,0,0,0}, 118 | { LEX_JBE, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0x76,OP_CMD_REL8,0,0,0,0,0,0,0}, 119 | { LEX_JC, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0x72,OP_CMD_REL8,0,0,0,0,0,0,0}, 120 | { LEX_JE, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0x74,OP_CMD_REL8,0,0,0,0,0,0,0}, 121 | { LEX_JG, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0x7f,OP_CMD_REL8,0,0,0,0,0,0,0}, 122 | { LEX_JGE, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0x7d,OP_CMD_REL8,0,0,0,0,0,0,0}, 123 | { LEX_JL, LEX_NONE,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}, 137 | { LEX_JNS, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0x79,OP_CMD_REL8,0,0,0,0,0,0,0}, 138 | { LEX_JNZ, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0x75,OP_CMD_REL8,0,0,0,0,0,0,0}, 139 | { LEX_JO, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0x70,OP_CMD_REL8,0,0,0,0,0,0,0}, 140 | { LEX_JP, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0x7a,OP_CMD_REL8,0,0,0,0,0,0,0}, 141 | { LEX_JPE, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0x7a,OP_CMD_REL8,0,0,0,0,0,0,0}, 142 | { LEX_JPO, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0x7b,OP_CMD_REL8,0,0,0,0,0,0,0}, 143 | { LEX_JS, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0x78,OP_CMD_REL8,0,0,0,0,0,0,0}, 144 | { LEX_JZ, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0x74,OP_CMD_REL8,0,0,0,0,0,0,0}, 145 | { LEX_LAHF, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0x9f,0,0,0,0,0,0,0,0}, 146 | { LEX_LDS, LEX_NONE, 2,REG_16,MEM_16,0,0,OP_CMD_OP,0xc5,OP_CMD_RM1_16,1,0,0,0,0,0,0}, 147 | { LEX_LES, LEX_NONE, 2,REG_16,MEM_16,0,0,OP_CMD_OP,0xc4,OP_CMD_RM1_16,1,0,0,0,0,0,0}, 148 | { LEX_LEA, LEX_NONE, 2,REG_16,MEM_16,0,0,OP_CMD_OP,0x8d,OP_CMD_RM1_16,1,0,0,0,0,0,0}, 149 | { LEX_LEAVE, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xc9,0,0,0,0,0,0,0,0}, 150 | { LEX_CMPSB, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xac,0,0,0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f7,OP_CMD_RMLINE_8,2,0,0,0,0,0,0}, 177 | { LEX_NOP, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0x90,0,0,0,0,0,0,0,0}, 178 | { LEX_OR, LEX_NONE, 2,ACC_8,IMM,0,0,OP_CMD_OP,0x0a,OP_CMD_IMM8,1,0,0,0,0,0,0}, 179 | { LEX_OR, LEX_NONE, 2,ACC_16,IMM,0,0,OP_CMD_OP,0x0b,OP_CMD_IMM16,1,0,0,0,0,0,0}, 180 | { LEX_OR, LEX_NONE, 2,RM_8,REG_8,0,0,OP_CMD_OP,0x08,OP_CMD_RM2_8,1,0,0,0,0,0,0}, 181 | { LEX_OR, LEX_NONE, 2,RM_16,REG_16,0,0,OP_CMD_OP,0x09,OP_CMD_RM2_16,1,0,0,0,0,0,0}, 182 | { LEX_OR, LEX_NONE, 2,REG_8,RM_8,0,0,OP_CMD_OP,0x0a,OP_CMD_RM1_8,1,0,0,0,0,0,0}, 183 | { LEX_OR, LEX_NONE, 2,REG_16,RM_16,0,0,OP_CMD_OP,0x0b,OP_CMD_RM1_16,1,0,0,0,0,0,0}, 184 | { LEX_OR, LEX_NONE, 2,RM_8,IMM,0,0,OP_CMD_OP,0x80,OP_CMD_RMLINE_8,1,0,OP_CMD_IMM8,1,0,0,0}, 185 | { LEX_OR, LEX_NONE, 2,RM_16,IMM,0,0,OP_CMD_OP,0x81,OP_CMD_RMLINE_16,1,0,OP_CMD_IMM16,1,0,0,0}, 186 | { LEX_OUT, LEX_NONE, 2,IMM,ACC_8,0,0,OP_CMD_OP,0xe6,OP_CMD_IMM8,0,0,0,0,0,0,0}, 187 | { LEX_OUT, LEX_NONE, 2,IMM,ACC_16,0,0,OP_CMD_OP,0xe7,OP_CMD_IMM8,0,0,0,0,0,0,0}, 188 | { LEX_OUT, LEX_NONE, 2,DX,ACC_8,0,0,OP_CMD_OP,0xee,0,0,0,0,0,0,0,0}, 189 | { LEX_OUT, LEX_NONE, 2,DX,ACC_16,0,0,OP_CMD_OP,0xef,0,0,0,0,0,0,0,0}, 190 | { LEX_OUTSB, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0x6e,0,0,0,0,0,0,0,0}, 191 | { LEX_OUTSW, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0x6f,0,0,0,0,0,0,0,0}, 192 | { LEX_LODSB, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xac,0,0,0,0,0,0,0,0}, 193 | { LEX_LODSW, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xad,0,0,0,0,0,0,0,0}, 194 | { LEX_POP, LEX_NONE, 1,REG_16,0,0,0,OP_CMD_PLUSREG16,0x58,0,0,0,0,0,0,0,0}, 195 | { LEX_POP, LEX_NONE, 1,RM_16,0,0,0,OP_CMD_OP,0x8f,OP_CMD_RMLINE_16,0,0,0,0,0,0,0}, 196 | { LEX_POP, LEX_NONE, 1,DS,0,0,0,OP_CMD_OP,0x1f,0,0,0,0,0,0,0,0}, 197 | { LEX_POP, LEX_NONE, 1,ES,0,0,0,OP_CMD_OP,0x07,0,0,0,0,0,0,0,0}, 198 | { LEX_POP, LEX_NONE, 1,SS,0,0,0,OP_CMD_OP,0x17,0,0,0,0,0,0,0,0}, 199 | { LEX_POPA, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0x61,0,0,0,0,0,0,0,0}, 200 | { LEX_POPF, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0x9d,0,0,0,0,0,0,0,0}, 201 | { LEX_PUSH, LEX_NONE, 1,RM_16,0,0,0,OP_CMD_OP,0xff,OP_CMD_RMLINE_16,6,0,0,0,0,0,0}, 202 | { LEX_PUSH, LEX_NONE, 1,REG_16,0,0,0,OP_CMD_PLUSREG16,0x50,0,0,0,0,0,0,0,0}, 203 | { LEX_PUSH, LEX_NONE, 1,CS,0,0,0,OP_CMD_OP,0x0e,0,0,0,0,0,0,0,0}, 204 | { LEX_PUSH, LEX_NONE, 1,DS,0,0,0,OP_CMD_OP,0x1e,0,0,0,0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,0,0,0,0}, 243 | { LEX_SAR1, LEX_NONE, 1,RM_8,0,0,0,OP_CMD_OP,0xd0,OP_CMD_RMLINE_8,7,0,0,0,0,0,0}, 244 | { LEX_SAR1, LEX_NONE, 1,RM_16,0,0,0,OP_CMD_OP,0xd1,OP_CMD_RMLINE_16,7,0,0,0,0,0,0}, 245 | { LEX_SAR, LEX_NONE, 2,RM_8,CL,0,0,OP_CMD_OP,0xD2,OP_CMD_RMLINE_8,7,0,0,0,0,0,0}, 246 | { LEX_SAR, LEX_NONE, 2,RM_16,CL,0,0,OP_CMD_OP,0xD3,OP_CMD_RMLINE_16,7,0,0,0,0,0,0}, 247 | { LEX_SAR, LEX_NONE, 2,RM_8,IMM,0,0,OP_CMD_OP,0xc0,OP_CMD_RMLINE_8,7,0,OP_CMD_IMM8,1,0,0,0}, 248 | { LEX_SAR, LEX_NONE, 2,RM_16,IMM,0,0,OP_CMD_OP,0xc1,OP_CMD_RMLINE_16,7,0,OP_CMD_IMM8,1,0,0,0}, 249 | { LEX_RET, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xc3,0,0,0,0,0,0,0,0}, 250 | { LEX_RET, LEX_NONE, 1,0,0,0,0,OP_CMD_OP,0xc2,OP_CMD_IMM16,0,0,0,0,0,0,0}, 251 | { LEX_RETF, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xcb,0,0,0,0,0,0,0,0}, 252 | { LEX_RETF, LEX_NONE, 1,0,0,0,0,OP_CMD_OP,0xca,OP_CMD_IMM16,0,0,0,0,0,0,0}, 253 | { LEX_SALC, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xd6,0,0,0,0,0,0,0,0}, 254 | { LEX_SBB, LEX_NONE, 2,ACC_8,IMM,0,0,OP_CMD_OP,0x1c,OP_CMD_IMM8,1,0,0,0,0,0,0}, 255 | { LEX_SBB, LEX_NONE, 2,ACC_16,IMM,0,0,OP_CMD_OP,0x1d,OP_CMD_IMM16,1,0,0,0,0,0,0}, 256 | { LEX_SBB, LEX_NONE, 2,REG_8,RM_8,0,0,OP_CMD_OP,0x1a,OP_CMD_RM1_8,1,0,0,0,0,0,0}, 257 | { LEX_SBB, LEX_NONE, 2,REG_16,RM_16,0,0,OP_CMD_OP,0x1b,OP_CMD_RM1_16,1,0,0,0,0,0,0}, 258 | { LEX_SBB, LEX_NONE, 2,RM_8,REG_8,0,0,OP_CMD_OP,0x18,OP_CMD_RM2_8,1,0,0,0,0,0,0}, 259 | { LEX_SBB, LEX_NONE, 2,RM_16,REG_16,0,0,OP_CMD_OP,0x19,OP_CMD_RM2_16,1,0,0,0,0,0,0}, 260 | { LEX_SBB, LEX_NONE, 2,RM_8,IMM,0,0,OP_CMD_OP,0x80,OP_CMD_RMLINE_8,3,0,OP_CMD_IMM8,1,0,0,0}, 261 | { LEX_SBB, LEX_NONE, 2,RM_16,IMM,0,0,OP_CMD_OP,0x81,OP_CMD_RMLINE_16,3,0,OP_CMD_IMM16,1,0,0,0}, 262 | { LEX_SCASB, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xae,0,0,0,0,0,0,0,0}, 263 | { LEX_SCASW, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xaf,0,0,0,0,0,0,0,0}, 264 | { LEX_SHL1, LEX_NONE, 1,RM_8,0,0,0,OP_CMD_OP,0xd0,OP_CMD_RMLINE_8,4,0,0,0,0,0,0}, 265 | { LEX_SHL1, LEX_NONE, 1,RM_16,0,0,0,OP_CMD_OP,0xd1,OP_CMD_RMLINE_16,4,0,0,0,0,0,0}, 266 | { LEX_SHL, LEX_NONE, 2,RM_8,CL,0,0,OP_CMD_OP,0xD2,OP_CMD_RMLINE_8,4,0,0,0,0,0,0}, 267 | { LEX_SHL, LEX_NONE, 2,RM_16,CL,0,0,OP_CMD_OP,0xD3,OP_CMD_RMLINE_16,4,0,0,0,0,0,0}, 268 | { LEX_SHL, LEX_NONE, 2,RM_8,IMM,0,0,OP_CMD_OP,0xc0,OP_CMD_RMLINE_8,4,0,OP_CMD_IMM8,1,0,0,0}, 269 | { LEX_SHL, LEX_NONE, 2,RM_16,IMM,0,0,OP_CMD_OP,0xc1,OP_CMD_RMLINE_16,4,0,OP_CMD_IMM8,1,0,0,0}, 270 | { LEX_SHR1, LEX_NONE, 1,RM_8,0,0,0,OP_CMD_OP,0xd0,OP_CMD_RMLINE_8,5,0,0,0,0,0,0}, 271 | { LEX_SHR1, LEX_NONE, 1,RM_16,0,0,0,OP_CMD_OP,0xd1,OP_CMD_RMLINE_16,5,0,0,0,0,0,0}, 272 | { LEX_SHR, LEX_NONE, 2,RM_8,CL,0,0,OP_CMD_OP,0xD2,OP_CMD_RMLINE_8,5,0,0,0,0,0,0}, 273 | { LEX_SHR, LEX_NONE, 2,RM_16,CL,0,0,OP_CMD_OP,0xD3,OP_CMD_RMLINE_16,5,0,0,0,0,0,0}, 274 | { LEX_SHR, LEX_NONE, 2,RM_8,IMM,0,0,OP_CMD_OP,0xc0,OP_CMD_RMLINE_8,5,0,OP_CMD_IMM8,1,0,0,0}, 275 | { LEX_SHR, LEX_NONE, 2,RM_16,IMM,0,0,OP_CMD_OP,0xc1,OP_CMD_RMLINE_16,5,0,OP_CMD_IMM8,1,0,0,0}, 276 | { LEX_STC, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xf9,0,0,0,0,0,0,0,0}, 277 | { LEX_STD, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xfd,0,0,0,0,0,0,0,0}, 278 | { LEX_STI, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xfb,0,0,0,0,0,0,0,0}, 279 | { LEX_STOSB, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xaa,0,0,0,0,0,0,0,0}, 280 | { LEX_STOSW, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xab,0,0,0,0,0,0,0,0}, 281 | { LEX_SUB, LEX_NONE, 2,ACC_8,IMM,0,0,OP_CMD_OP,0x2c,OP_CMD_IMM8,1,0,0,0,0,0,0}, 282 | { LEX_SUB, LEX_NONE, 2,ACC_16,IMM,0,0,OP_CMD_OP,0x2d,OP_CMD_IMM16,1,0,0,0,0,0,0}, 283 | { LEX_SUB, LEX_NONE, 2,RM_8,REG_8,0,0,OP_CMD_OP,0x28,OP_CMD_RM2_8,1,0,0,0,0,0,0}, 284 | { LEX_SUB, LEX_NONE, 2,RM_16,REG_16,0,0,OP_CMD_OP,0x29,OP_CMD_RM2_16,1,0,0,0,0,0,0}, 285 | { LEX_SUB, LEX_NONE, 2,REG_8,RM_8,0,0,OP_CMD_OP,0x2a,OP_CMD_RM1_8,1,0,0,0,0,0,0}, 286 | { LEX_SUB, LEX_NONE, 2,REG_16,RM_16,0,0,OP_CMD_OP,0x2b,OP_CMD_RM1_16,1,0,0,0,0,0,0}, 287 | { LEX_SUB, LEX_NONE, 2,RM_8,IMM,0,0,OP_CMD_OP,0x80,OP_CMD_RMLINE_8,5,0,OP_CMD_IMM8,1,0,0,0}, 288 | { LEX_SUB, LEX_NONE, 2,RM_16,IMM,0,0,OP_CMD_OP,0x81,OP_CMD_RMLINE_16,5,0,OP_CMD_IMM16,1,0,0,0}, 289 | { LEX_TEST, LEX_NONE, 2,RM_8,REG_8,0,0,OP_CMD_OP,0x84,OP_CMD_RM2_8,1,0,0,0,0,0,0}, 290 | { LEX_TEST, LEX_NONE, 2,RM_16,REG_16,0,0,OP_CMD_OP,0x85,OP_CMD_RM2_16,1,0,0,0,0,0,0}, 291 | { LEX_TEST, LEX_NONE, 2,RM_8,IMM,0,0,OP_CMD_OP,0xf6,OP_CMD_RMLINE_8,0,0,OP_CMD_IMM8,1,0,0,0}, 292 | { LEX_TEST, LEX_NONE, 2,RM_16,IMM,0,0,OP_CMD_OP,0xf7,OP_CMD_RMLINE_16,0,0,OP_CMD_IMM16,1,0,0,0}, 293 | { LEX_WAIT, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0x9b,0,0,0,0,0,0,0,0}, 294 | { LEX_XCHG, LEX_NONE, 2,ACC_16,REG_16,0,0,OP_CMD_PLUSREG16,0x90,1,0,0,0,0,0,0,0}, 295 | { LEX_XCHG, LEX_NONE, 2,RM_8,REG_8,0,0,OP_CMD_OP,0x86,OP_CMD_RM2_8,1,0,0,0,0,0,0}, 296 | { LEX_XCHG, LEX_NONE, 2,RM_16,REG_16,0,0,OP_CMD_OP,0x87,OP_CMD_RM2_16,1,0,0,0,0,0,0}, 297 | { LEX_XCHG, LEX_NONE, 2,REG_8,RM_8,0,0,OP_CMD_OP,0x86,OP_CMD_RM1_8,1,0,0,0,0,0,0}, 298 | { LEX_XCHG, LEX_NONE, 2,REG_16,RM_16,0,0,OP_CMD_OP,0x87,OP_CMD_RM1_16,1,0,0,0,0,0,0}, 299 | { LEX_XLATB, LEX_NONE, 0,0,0,0,0,OP_CMD_OP,0xd7,0,0,0,0,0,0,0,0}, 300 | { LEX_XOR, LEX_NONE, 2,ACC_8,IMM,0,0,OP_CMD_OP,0x34,OP_CMD_IMM8,1,0,0,0,0,0,0}, 301 | { LEX_XOR, LEX_NONE, 2,ACC_16,IMM,0,0,OP_CMD_OP,0x35,OP_CMD_IMM16,1,0,0,0,0,0,0}, 302 | { LEX_XOR, LEX_NONE, 2,RM_8,REG_8,0,0,OP_CMD_OP,0x30,OP_CMD_RM2_8,1,0,0,0,0,0,0}, 303 | { LEX_XOR, LEX_NONE, 2,RM_16,REG_16,0,0,OP_CMD_OP,0x31,OP_CMD_RM2_16,1,0,0,0,0,0,0}, 304 | { LEX_XOR, LEX_NONE, 2,REG_8,RM_8,0,0,OP_CMD_OP,0x32,OP_CMD_RM1_8,1,0,0,0,0,0,0}, 305 | { LEX_XOR, LEX_NONE, 2,REG_16,RM_16,0,0,OP_CMD_OP,0x33,OP_CMD_RM1_16,1,0,0,0,0,0,0}, 306 | { LEX_XOR, LEX_NONE, 2,RM_8,IMM,0,0,OP_CMD_OP,0x80,OP_CMD_RMLINE_8,6,0,OP_CMD_IMM8,1,0,0,0}, 307 | { LEX_XOR, LEX_NONE, 2,RM_16,IMM,0,0,OP_CMD_OP,0x81,OP_CMD_RMLINE_16,6,0,OP_CMD_IMM16,1,0,0,0}, 308 | { LEX_INT, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0xcd,OP_CMD_IMM8,0,0,0,0,0,0,0}, 309 | { LEX_JMP, LEX_FAR, 2,IMM,IMM,0,0,OP_CMD_OP,0xea,OP_CMD_IMM16,1,OP_CMD_IMM16,0,0,0,0,0}, 310 | { LEX_JMP, LEX_SHORT, 1,IMM,0,0,0,OP_CMD_OP,0xeb,OP_CMD_REL8,0,0,0,0,0,0,0}, 311 | { LEX_JMP, LEX_NONE, 1,IMM,0,0,0,OP_CMD_OP,0xe9,OP_CMD_REL16,0,0,0,0,0,0,0}, 312 | { LEX_JMP, LEX_NEAR, 1,IMM,0,0,0,OP_CMD_OP,0xe9,OP_CMD_REL16,0,0,0,0,0,0,0}, 313 | { LEX_JMP, LEX_NONE, 1,RM_16,0,0,0,OP_CMD_OP,0xff,OP_CMD_RMLINE_16,4,0,0,0,0,0,0}, 314 | { LEX_NONE, LEX_NONE, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} 315 | }; 316 | --------------------------------------------------------------------------------