LTCD_060719.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:45:17 +02:00
commit f86e69648b
156 files changed
+49537

No files matched your search

+1411
View File
File diff suppressed because it is too large. Load diff
+881
View File
@@ -0,0 +1,881 @@
/*
'%'= 32 bit
'*'= 16 bit
'!'= don't switch modes
'&'= default
*/
R8 AL 0;
R8 CL 1;
R8 DL 2;
R8 BL 3;
R8 AH 4;
R8 CH 5;
R8 DH 6;
R8 BH 7;
R16 AX 0;
R16 CX 1;
R16 DX 2;
R16 BX 3;
R16 SP 4;
R16 BP 5;
R16 SI 6;
R16 DI 7;
R32 EAX 0;
R32 ECX 1;
R32 EDX 2;
R32 EBX 3;
R32 ESP 4;
R32 EBP 5;
R32 ESI 6;
R32 EDI 7;
SEG ES 0;
SEG CS 1;
SEG SS 2;
SEG DS 3;
SEG FS 4;
SEG GS 5;
KEYWORD include 0;
KEYWORD define 1;
KEYWORD union 2;
KEYWORD catch 3;
KEYWORD class 4;
KEYWORD try 5;
KEYWORD if 6;
KEYWORD else 7;
KEYWORD for 8;
KEYWORD while 9;
KEYWORD extern 10;
KEYWORD LTextern 11;
KEYWORD return 12;
KEYWORD sizeof 13;
KEYWORD LTintern 14;
KEYWORD fmtstr 15;
KEYWORD fmtdata 16;
KEYWORD output_fun 17;
KEYWORD input_fun 18;
KEYWORD cout 19;
KEYWORD dbgo 19; /*used for debugging*/
KEYWORD do 20;
KEYWORD asm 21;
KEYWORD goto 22;
KEYWORD exe 23;
KEYWORD break 24;
KEYWORD continue 25;
KEYWORD switch 26;
KEYWORD case 27;
KEYWORD default 28;
KEYWORD public 29;
KEYWORD offset 30;
KEYWORD typeof 31;
KEYWORD import 32;
KEYWORD LTimport 33;
KEYWORD coutln 34;
KEYWORD dbgoln 34;
KEYWORD ALIGN 64;
KEYWORD END 65;
KEYWORD U1 66;
KEYWORD U2 67;
KEYWORD U4 68;
KEYWORD U8 68; /*ALIAS*/
KEYWORD DU1 69;
KEYWORD DU2 70;
KEYWORD DU4 71;
KEYWORD DUP 72;
KEYWORD ORG 73;
KEYWORD STRUC 74;
KEYWORD ENDS 75;
KEYWORD USE16 76;
KEYWORD USE32 77;
KEYWORD IMPORT 78;
KEYWORD EXPORT 79;
KEYWORD INSERT 80;
KEYWORD LIST 81;
KEYWORD NOLIST 82;
KEYWORD INSERT_COMPRESSED 83;
KEYWORD DU8 84;
OPCODE PUSH
0x0E NO CS
0x16 NO SS
0x1E NO DS
0x06 NO ES
0x0F 0xA0 NO FS
0x0F 0xA8 NO GS
0x6A &IB IMM8
0x68 *!IW IMM16
0x68 %!ID IMM32
0x50 +/R *NO R16
0x50 +/R %NO R32
0xFF /6 *NO RM16
0xFF /6 %NO RM32;
OPCODE PUSHA 0x60 NO;
OPCODE PUSHAW 0x60 *NO;
OPCODE PUSHAD 0x60 %NO;
OPCODE PUSHF 0x9C NO;
OPCODE PUSHFW 0x9C *NO;
OPCODE PUSHFD 0x9C %NO;
OPCODE POP
0x1F NO DS
0x07 NO ES
0x17 NO SS
0x0F 0xA1 NO FS
0x0F 0xA9 NO GS
0x58 +*RW R16
0x58 +%RD R32
0x8F /0 *NO RM16
0x8F /0 %NO RM32;
OPCODE POPA 0x61 NO;
OPCODE POPAW 0x61 *NO;
OPCODE POPAD 0x61 %NO;
OPCODE POPF 0x9D NO;
OPCODE POPFW 0x9D *NO;
OPCODE POPFD 0x9D %NO;
OPCODE MOV
// 0xA0 NO AL MOFFS8
0xA1 *NO AX MOFFS16
0xA1 %NO EAX MOFFS32
// 0xA2 NO MOFFS8 AL
0xA3 *NO MOFFS16 AX
0xA3 %NO MOFFS32 EAX
0x8A /R NO R8 RM8
0x8B /R *NO R16 RM16
0x8B /R %NO R32 RM32
0x88 /R NO RM8 R8
0x89 /R *NO RM16 R16
0x89 /R %NO RM32 R32
0x8C /R %NO RM16 SREG
0x8E /R %NO SREG RM16
0xB0 +RB R8 UIMM8
0xB8 +*RW R16 UIMM16
0xB8 +%RD R32 UIMM32
0xC6 NO RM8 UIMM8
0xC7 *NO RM16 UIMM16
0xC7 %NO RM32 UIMM32;
OPCODE ADC
0x14 IB AL UIMM8
0x15 *IW AX UIMM16
0x15 %ID EAX UIMM32
0x80 /2 IB RM8 UIMM8
0x83 /2 *IB RM16 IMM8
0x83 /2 %IB RM32 IMM8
0x81 /2 *IW RM16 UIMM16
0x81 /2 %ID RM32 UIMM32
0x12 /R NO R8 RM8
0x13 /R *NO R16 RM16
0x13 /R %NO R32 RM32
0x10 /R NO RM8 R8
0x11 /R *NO RM16 R16
0x11 /R %NO RM32 R32;
OPCODE ADD
0x04 IB AL UIMM8
0x05 *IW AX UIMM16
0x05 %ID EAX UIMM32
0x80 /0 IB RM8 UIMM8
0x83 /0 *IB RM16 IMM8
0x83 /0 %IB RM32 IMM8
0x81 /0 *IW RM16 UIMM16
0x81 /0 %ID RM32 UIMM32
0x02 /R NO R8 RM8
0x03 /R *NO R16 RM16
0x03 /R %NO R32 RM32
0x00 /R NO RM8 R8
0x01 /R *NO RM16 R16
0x01 /R %NO RM32 R32;
OPCODE AND
0x24 IB AL UIMM8
0x25 *IW AX UIMM16
0x25 %ID EAX UIMM32
0x80 /4 IB RM8 UIMM8
0x83 /4 *IB RM16 IMM8
0x83 /4 %IB RM32 IMM8
0x81 /4 *IW RM16 UIMM16
0x81 /4 %ID RM32 UIMM32
0x22 /R NO R8 RM8
0x23 /R *NO R16 RM16
0x23 /R %NO R32 RM32
0x20 /R NO RM8 R8
0x21 /R *NO RM16 R16
0x21 /R %NO RM32 R32;
OPCODE CMP
0x3C IB AL UIMM8
0x3D *IW AX UIMM16
0x3D %ID EAX UIMM32
0x80 /7 IB RM8 UIMM8
0x83 /7 *IB RM16 IMM8
0X83 /7 %IB RM32 IMM8
0x81 /7 *IW RM16 UIMM16
0x81 /7 %ID RM32 UIMM32
0x3A /R NO R8 RM8
0x3B /R *NO R16 RM16 //ERROR?
0x3B /R %NO R32 RM32
0x38 /R NO RM8 R8
0x39 /R *NO RM16 R16
0x39 /R %NO RM32 R32;
OPCODE OR
0x0C IB AL UIMM8
0x0D *IW AX UIMM16
0x0D %ID EAX UIMM32
0x80 /1 IB RM8 UIMM8
0x83 /1 *IB RM16 IMM8
0x83 /1 %IB RM32 IMM8
0x81 /1 *IW RM16 UIMM16
0x81 /1 %ID RM32 UIMM32
0x0A /R NO R8 RM8
0x0B /R *NO R16 RM16
0x0B /R %NO R32 RM32
0x08 /R NO RM8 R8
0x09 /R *NO RM16 R16
0x09 /R %NO RM32 R32;
OPCODE SBB
0x1C IB AL UIMM8
0x1D *IW AX UIMM16
0x1D %ID EAX UIMM32
0x80 /3 IB RM8 UIMM8
0x83 /3 *IB RM16 IMM8
0x83 /3 %IB RM32 IMM8
0x81 /3 *IW RM16 UIMM16
0x81 /3 %ID RM32 UIMM32
0x1A /R NO R8 RM8
0x1B /R *NO R16 RM16
0x1B /R %NO R32 RM32
0x18 /R NO RM8 R8
0x19 /R *NO RM16 R16
0x19 /R %NO RM32 R32;
OPCODE SUB
0x2C IB AL UIMM8
0x2D *IW AX UIMM16
0x2D %ID EAX UIMM32
0x80 /5 IB RM8 UIMM8
0x83 /5 *IB RM16 IMM8
0x83 /5 %IB RM32 IMM8
0x81 /5 *IW RM16 UIMM16
0x81 /5 %ID RM32 UIMM32
0x2A /R NO R8 RM8
0x2B /R *NO R16 RM16
0x2B /R %NO R32 RM32
0x28 /R NO RM8 R8
0x29 /R *NO RM16 R16
0x29 /R %NO RM32 R32;
OPCODE TEST
0xA8 IB AL UIMM8
0xA9 *IW AX UIMM16
0xA9 %ID EAX UIMM32
0xF6 /0 IB RM8 UIMM8
0xF7 /0 *IW RM16 UIMM16
0xF7 /0 %ID RM32 UIMM32
0x84 /R NO RM8 R8
0x85 /R *NO RM16 R16
0x85 /R %NO RM32 R32;
OPCODE NOP 0x90 NO;
OPCODE XCHG
0x90 +/R *NO R16 AX
0x90 +/R *NO AX R16
0x90 +/R %NO R32 EAX
0x90 +/R %NO EAX R32
0x86 /R NO R8 RM8
0x87 /R *NO R16 RM16
0x87 /R %NO R32 RM32
0x86 /R NO RM8 R8
0x87 /R *NO RM16 R16
0x87 /R %NO RM32 R32;
OPCODE XOR
0x34 IB AL UIMM8
0x35 *IW AX UIMM16
0x35 %ID EAX UIMM32
0x80 /6 IB RM8 UIMM8
0x83 /6 *IB RM16 IMM8
0x83 /6 %IB RM32 IMM8
0x81 /6 *IW RM16 UIMM16
0x81 /6 %ID RM32 UIMM32
0x32 /R NO R8 RM8
0x33 /R *NO R16 RM16
0x33 /R %NO R32 RM32
0x30 /R NO RM8 R8
0x31 /R *NO RM16 R16
0x31 /R %NO RM32 R32;
OPCODE CALL
0xE8 *!&CW REL16
0xFF /2 *!NO RM16
0xE8 %!&CD REL32
0xFF /2 %!NO RM32
// 0x9A CD PTR1616
// 0xFF /3 *NO M1616
// 0x9A *CP PTR1632
// 0x9A %CP PTR3232
// 0xFF /3 %NO M1632
;
OPCODE JMP
0xEB &CB REL8
0xE9 *!CW REL16
0xE9 %!CD REL32
0xFF /4 *!NO RM16
0xFF /4 %!NO RM32;
OPCODE JA
0x77 &CB REL8
0x0F 0x87 *!CW REL16
0x0F 0x87 %!CD REL32;
OPCODE JAE
0x73 &CB REL8
0x0F 0x83 *!CW REL16
0x0F 0x83 %!CD REL32;
OPCODE JB
0x72 &CB REL8
0x0F 0x82 *!CW REL16
0x0F 0x82 %!CD REL32;
OPCODE JBE
0x76 &CB REL8
0x0F 0x86 *!CW REL16
0x0F 0x86 %!CD REL32;
OPCODE JC
0x72 &CB REL8
0x0F 0x82 *!CW REL16
0x0F 0x82 %!CD REL32;
OPCODE JCXZ
0xE3 CB REL8;
OPCODE JECXZ
0xE3 CB REL8;
OPCODE JE
0x74 &CB REL8
0x0F 0x84 *!CW REL16
0x0F 0x84 %!CD REL32;
OPCODE JZ
0x74 &CB REL8
0x0F 0x84 *!CW REL16
0x0F 0x84 %!CD REL32;
OPCODE JG
0x7F &CB REL8
0x0F 0x8F *!CW REL16
0x0F 0x8F %!CD REL32;
OPCODE JGE
0x7D &CB REL8
0x0F 0x8D *!CW REL16
0x0F 0x8D %!CD REL32;
OPCODE JL
0x7C &CB REL8
0x0F 0x8C *!CW REL16
0x0F 0x8C %!CD REL32;
OPCODE JLE
0x7E &CB REL8
0x0F 0x8E *!CW REL16
0x0F 0x8E %!CD REL32;
OPCODE JNA
0x76 &CB REL8
0x0F 0x86 *!CW REL16
0x0F 0x86 %!CD REL32;
OPCODE JNAE
0x72 &CB REL8
0x0F 0x82 *!CW REL16
0x0F 0x82 %!CD REL32;
OPCODE JNB
0x73 &CB REL8
0x0F 0x83 *!CW REL16
0x0F 0x83 %!CD REL32;
OPCODE JNBE
0x77 &CB REL8
0x0F 0x87 *!CW REL16
0x0F 0x87 %!CD REL32;
OPCODE JNC
0x73 &CB REL8
0x0F 0x83 *!CW REL16
0x0F 0x83 %!CD REL32;
OPCODE JNE
0x75 &CB REL8
0x0F 0x85 *!CW REL16
0x0F 0x85 %!CD REL32;
OPCODE JNG
0x7E &CB REL8
0x0F 0x8E *!CW REL16
0x0F 0x8E %!CD REL32;
OPCODE JNGE
0x7C &CB REL8
0x0F 0x8C *!CW REL16
0x0F 0x8C %!CD REL32;
OPCODE JNL
0x7D &CB REL8
0x0F 0x8D *!CW REL16
0x0F 0x8D %!CD REL32;
OPCODE JNLE
0x7F &CB REL8
0x0F 0x8F *!CW REL16
0x0F 0x8F %!CD REL32;
OPCODE JNO
0x71 &CB REL8
0x0F 0x81 *!CW REL16
0x0F 0x81 %!CD REL32;
OPCODE JNP
0x7B &CB REL8
0x0F 0x8B *!CW REL16
0x0F 0x8B %!CD REL32;
OPCODE JNS
0x79 &CB REL8
0x0F 0x89 *!CW REL16
0x0F 0x89 %!CD REL32;
OPCODE JNZ
0x75 &CB REL8
0x0F 0x85 *!CW REL16
0x0F 0x85 %!CD REL32;
OPCODE JO
0x70 &CB REL8
0x0F 0x80 *!CW REL16
0x0F 0x80 %!CD REL32;
OPCODE JP
0x7A &CB REL8
0x0F 0x8A *!CW REL16
0x0F 0x8A %!CD REL32;
OPCODE JPE
0x7A &CB REL8
0x0F 0x8A *!CW REL16
0x0F 0x8A %!CD REL32;
OPCODE JPO
0x7B &CB REL8
0x0F 0x8B *!CW REL16
0x0F 0x8B %!CD REL32;
OPCODE JS
0x78 &CB REL8
0x0F 0x88 *!CW REL16
0x0F 0x88 %!CD REL32;
OPCODE JZ
0x74 &CB REL8
0x0F 0x84 *!CW REL16
0x0F 0x84 %!CD REL32;
OPCODE INC
0x40 +*RW R16
0x40 +%RD R32
0xFE /0 NO RM8
0xFF /0 *NO RM16
0xFF /0 %NO RM32;
OPCODE DEC
0x48 +*RW R16
0x48 +%RD R32
0xFE /1 NO RM8
0xFF /1 *NO RM16
0xFF /1 %NO RM32;
OPCODE NOT
0xF6 /2 NO RM8
0xF7 /2 *NO RM16
0xF7 /2 %NO RM32;
OPCODE NEG
0xF6 /3 NO RM8
0xF7 /3 *NO RM16
0xF7 /3 %NO RM32;
OPCODE MUL
0xF6 /4 NO RM8
0xF7 /4 *NO RM16
0xF7 /4 %NO RM32;
OPCODE IMUL
0xF6 /5 NO RM8
0xF7 /5 *NO RM16
0xF7 /5 %NO RM32;
OPCODE IMUL2
0x0F 0xAF /R *NO R16 RM16
0x0F 0xAF /R *NO R32 RM32
0x6B /R *IB RM16 IMM8
0x6B /R %IB RM32 IMM8
0x69 /R *IW RM16 UIMM16
0x69 /R %ID RM32 UIMM32;
OPCODE DIV
0xF6 /6 NO RM8
0xF7 /6 *NO RM16
0xF7 /6 %NO RM32;
OPCODE IDIV
0xF6 /7 NO RM8
0xF7 /7 *NO RM16
0xF7 /7 %NO RM32;
OPCODE AAA 0x37 NO;
OPCODE AAD 0xD5 0x0A NO;
OPCODE AAM 0xD4 0x0A NO;
OPCODE AAS 0x3F NO;
OPCODE ARPL 0x63 /R NO RM16 R16;
OPCODE BOUND
0x62 /R *NO RM16 R16
0x62 /R %NO RM32 R32;
OPCODE BSF
0x0F 0xBC /R *NO R16 RM16
0x0F 0xBC /R %NO R32 RM32;
OPCODE BSR
0x0F 0xBD /R *NO R16 RM16
0x0F 0xBD /R %NO R32 RM32;
OPCODE BSWAP
0x0F 0xC8 /R %NO R32;
OPCODE BT
0x0F 0xA3 /R *NO RM16 R16
0x0F 0xA3 /R %NO RM32 R32
0x0F 0xBA /4 *IB RM16 UIMM8
0x0F 0xBA /4 %IB RM32 UIMM8;
OPCODE BTC
0x0F 0xBB /R *NO RM16 R16
0x0F 0xBB /R %NO RM32 R32
0x0F 0xBA /7 *IB RM16 UIMM8
0x0F 0xBA /7 %IB RM32 UIMM8;
OPCODE BTR
0x0F 0xB3 /R *NO RM16 R16
0x0F 0xB3 /R %NO RM32 R32
0x0F 0xBA /6 *IB RM16 UIMM8
0x0F 0xBA /6 %IB RM32 UIMM8;
OPCODE BTS
0x0F 0xAB /R *NO RM16 R16
0x0F 0xAB /R %NO RM32 R32
0x0F 0xBA /5 *IB RM16 UIMM8
0x0F 0xBA /5 %IB RM32 UIMM8;
OPCODE CBW 0x98 NO;
OPCODE CDQ 0x99 NO;
OPCODE CLC 0xF8 NO;
OPCODE CLD 0xFC NO;
OPCODE CLI 0xFA NO;
OPCODE CLTS 0x0F 0x06 NO;
OPCODE CMC 0xF5 NO;
OPCODE CMPSB 0xA6 NO;
OPCODE CMPSW 0xA7 *NO;
OPCODE CMPSD 0xA7 %NO;
OPCODE CMPXCHG
0x0F 0xB0 /R NO RM8 R8
0x0F 0xB1 /R *NO RM16 R16
0x0F 0xB1 /R %NO RM32 R32;
//OPCODE CHPXCHG8B 0x0F 0xC7 NO RM64
OPCODE CPUID 0x0F 0xA2 NP;
OPCODE CWD 0x99 NO;
OPCODE CWDE 0x98 NO;
OPCODE DAA 0x27 NO;
OPCODE DAS 0x2F NO;
//OPCODE ENTER 0xC8 IW IB IMM16 IMM8;
OPCODE HLT 0xF4 NO;
OPCODE IN
0xE4 IB AL UIMM8
0xE5 *IB AX UIMM8
0xE5 %IB EAX UIMM8
0xEC NO AL DX
0xED *NO AX DX
0xED %NO EAX DX;
OPCODE INS
0x6C NO RM8 DX
0x6D *NO RM16 DX
0x6D %NO RM32 DX;
OPCODE INSB 0x6C NO;
OPCODE INSW 0x6D *NO;
OPCODE INSD 0x6D %NO;
OPCODE INTO 0xCE NO;
OPCODE INT3 0xCC NO;
OPCODE INT 0xCD IB IMM8;
OPCODE INVD 0x0F 0x08 NO;
//OPCODE INVLPG 0x0F 0x07 /7 M;
OPCODE IRET 0xCF NO;
OPCODE LAHF 0x9F NO;
OPCODE LAR
0x0F 0x02 /R *NO R16 RM16
0x0F 0x02 /R %NO R32 RM32;
OPCODE LEA
0x8D /R *NO R16 RM16
0x8D /R %NO R32 RM32;
OPCODE LEAVE 0xC9 NO;
OPCODE LGDT
0x0F 0x01 /2 *NO M16
0x0F 0x01 /2 %NO M32;
OPCODE LIDT
0x0F 0x01 /3 *NO M16
0x0F 0x01 /3 %NO M32;
//OPCODE LGS LSS LFS LDS LES
OPCODE LLDT
0x0F 0x00 /2 *NO RM16
0x0F 0x00 /2 %NO RM32;
OPCODE LMSW
0x0F 0x01 /6 *NO RM16
0x0F 0x01 /6 %NO RM32;
OPCODE LOCK 0xF0 NO;
OPCODE LODSB 0xAC NO;
OPCODE LODSW 0xAD *NO;
OPCODE LODSD 0xAD %NO;
OPCODE LOOP 0xE2 CB REL8;
OPCODE LOOPE 0xE1 CB REL8;
OPCODE LOOPZ 0xE1 CB REL8;
OPCODE LOOPNE 0xE0 CB REL8;
OPCODE LOOPNZ 0xE0 CB REL8;
OPCODE LSL
0x0F 0x03 /R *NO R16 RM16
0x0F 0x03 /R %NO R32 RM32;
OPCODE LTR
0x0F 0x00 /3 *NO RM16
0x0F 0x00 /3 %NO RM32;
OPCODE MOVSB 0xA4 NO;
OPCODE MOVSW 0xA5 *NO;
OPCODE MOVSD 0xA5 %NO;
OPCODE MOVSX
0x0F 0xBE /R *NO R16 RM8
0x0F 0xBE /R %NO R32 RM8
0x0F 0xBF /R %NO R32 RM16;
OPCODE MOVZX
0x0F 0xB6 /R *NO R16 RM8
0x0F 0xB6 /R %NO R32 RM8
0x0F 0xB7 /R %NO R32 RM16;
OPCODE OUT
0xE6 IB UIMM8 AL
0xE7 *IB UIMM8 AX
0xE7 %IB UIMM8 EAX
0xEE NO DX AL
0xEF *NO DX AX
0xEF %NO DX EAX;
OPCODE OUTSB 0x6E NO;
OPCODE OUTSW 0x6F *NO;
OPCODE OUTSD 0x6F %NO;
OPCODE RDMSR 0x0F 0x32 NO;
OPCODE REP_INSB 0xF3 0x6C NO;
OPCODE REP_INSW 0xF3 0x6D *NO;
OPCODE REP_INSD 0xF3 0x6D %NO;
OPCODE REP_MOVSB 0xF3 0xA4 NO;
OPCODE REP_MOVSW 0xF3 0xA5 *NO;
OPCODE REP_MOVSD 0xF3 0xA5 %NO;
OPCODE REP_OUTSB 0xF3 0x6E NO;
OPCODE REP_OUTSW 0xF3 0x6F *NO;
OPCODE REP_OUTSD 0xF3 0x6F %NO;
OPCODE REP_LODSB 0xF2 0xAC NO;
OPCODE REP_LODSW 0xF2 0xAD *NO;
OPCODE REP_LODSD 0xF2 0xAD %NO;
OPCODE REP_STOSB 0xF3 0xAA NO;
OPCODE REP_STOSW 0xF3 0xAB *NO;
OPCODE REP_STOSD 0xF3 0xAB %NO;
OPCODE REPE_CMPSB 0xF3 0xA6 NO;
OPCODE REPE_CMPSW 0xF3 0xA7 *NO;
OPCODE REPE_CMPSD 0xF3 0xA7 %NO;
OPCODE REPE_SCASB 0xF3 0xAE NO;
OPCODE REPE_SCASW 0xF3 0xAF *NO;
OPCODE REPE_SCASD 0xF3 0xAF %NO;
OPCODE REPNE_CMPSB 0xF2 0xA6 NO;
OPCODE REPNE_CMPSW 0xF2 0xA7 *NO;
OPCODE REPNE_CMPSD 0xF2 0xA7 %NO;
OPCODE REPNE_SCASB 0xF2 0xAE NO;
OPCODE REPNE_SCASW 0xF2 0xAF *NO;
OPCODE REPNE_SCASD 0xF2 0xAF %NO;
OPCODE RET 0xC3 NO;
OPCODE RET2 0xC2 IW UIMM16;
OPCODE RETF 0xCB NO;
OPCODE RETF2 0xCA IW UIMM16;
OPCODE RSM 0x0F 0xAA NO;
OPCODE SAHF 0x9E NO;
OPCODE SCASB 0xAE NO;
OPCODE SCASW 0xAF *NO;
OPCODE SCASD 0xAF %NO;
OPCODE SEGCS 0x2E NO;
OPCODE SEGSS 0x36 NO;
OPCODE SEGDS 0x3E NO;
OPCODE SEGES 0x26 NO;
OPCODE SEGFS 0x64 NO;
OPCODE SEGGS 0x65 NO;
OPCODE SETA 0x0F 0x97 NO RM8;
OPCODE SETAE 0x0F 0x93 NO RM8;
OPCODE SETB 0x0F 0x92 NO RM8;
OPCODE SETBE 0x0F 0x96 NO RM8;
OPCODE SETC 0x0F 0x92 NO RM8;
OPCODE SETE 0x0F 0x94 NO RM8;
OPCODE SETG 0x0F 0x9F NO RM8;
OPCODE SETGE 0x0F 0x9D NO RM8;
OPCODE SETL 0x0F 0x9C NO RM8;
OPCODE SETLE 0x0F 0x9E NO RM8;
OPCODE SETNA 0x0F 0x96 NO RM8;
OPCODE SETNAE 0x0F 0x92 NO RM8;
OPCODE SETNB 0x0F 0x93 NO RM8;
OPCODE SETNBE 0x0F 0x97 NO RM8;
OPCODE SETNC 0x0F 0x93 NO RM8;
OPCODE SETNE 0x0F 0x95 NO RM8;
OPCODE SETNG 0x0F 0x9E NO RM8;
OPCODE SETNGE 0x0F 0x9C NO RM8;
OPCODE SETNL 0x0F 0x9D NO RM8;
OPCODE SETNLE 0x0F 0x9F NO RM8;
OPCODE SETNO 0x0F 0x91 NO RM8;
OPCODE SETNP 0x0F 0x9B NO RM8;
OPCODE SETNS 0x0F 0x99 NO RM8;
OPCODE SETNZ 0x0F 0x95 NO RM8;
OPCODE SETO 0x0F 0x90 NO RM8;
OPCODE SETP 0x0F 0x9A NO RM8;
OPCODE SETPE 0x0F 0x9A NO RM8;
OPCODE SETPO 0x0F 0x9B NO RM8;
OPCODE SETS 0x0F 0x98 NO RM8;
OPCODE SETZ 0x0F 0x94 NO RM8;
//OPCODE SGDT 0x0F 0x01 /0 m
//OPCODE SIDT 0x0F 0x01 /0 m
OPCODE SHLD
0x0F 0xA5 /R *NO RM16 R16
0x0F 0xA5 /R %NO RM32 R32;
OPCODE SHRD
0x0F 0xAD /R *NO RM16 R16
0x0F 0xAD /R %NO RM32 R32;
OPCODE SLDT
0x0F 0x00 /0 *NO RM16
0x0F 0x00 /0 %NO RM32;
OPCODE SMSW
0x0F 0x01 /4 *NO RM16
0x0F 0x01 /4 %NO RM32;
OPCODE STC 0xF9 NO;
OPCODE STD 0xFD NO;
OPCODE STI 0xFB NO;
OPCODE STOSB 0xAA NO;
OPCODE STOSW 0xAB *NO;
OPCODE STOSD 0xAB %NO;
OPCODE STR
0x0F 0x00 /1 *NO RM16
0x0F 0x00 /1 %NO RM32;
OPCODE VERR
0x0F 0x00 /4 *NO RM16
0x0F 0x00 /4 %NO RM32;
OPCODE VERW
0x0F 0x00 /5 *NO RM16
0x0F 0x00 /5 %NO RM32;
OPCODE WAIT 0x9B NO;
OPCODE WBINVD 0x0F 0x09 NO;
OPCODE WRMSR 0x0F 0x30 NO;
OPCODE XADD
0x0F 0xC0 /R NO RM8 R8
0x0F 0xC1 /R *NO RM16 R16
0x0F 0xC1 /R %NO RM32 R32;
OPCODE XLATB 0xD7 NO;
OPCODE RCL
0xD2 /2 NO RM8 CL
0xD3 /2 *NO RM16 CL
0xD3 /2 %NO RM32 CL
0xC0 /2 IB RM8 UIMM8
0xC1 /2 *IB RM16 UIMM8
0xC1 /2 %IB RM32 UIMM8;
OPCODE RCL1
0xD0 /2 NO RM8
0xD1 /2 *NO RM16
0xD1 /2 %NO RM32;
OPCODE RCR
0xD2 /3 NO RM8 CL
0xD3 /3 *NO RM16 CL
0xD3 /3 %NO RM32 CL
0xC0 /3 IB RM8 UIMM8
0xC1 /3 *IB RM16 UIMM8
0xC1 /3 %IB RM32 UIMM8;
OPCODE RCR1
0xD0 /3 NO RM8
0xD1 /3 *NO RM16
0xD1 /3 %NO RM32;
OPCODE ROL
0xD2 /0 NO RM8 CL
0xD3 /0 *NO RM16 CL
0xD3 /0 %NO RM32 CL
0xC0 /0 IB RM8 UIMM8
0xC1 /0 *IB RM16 UIMM8
0xC1 /0 %IB RM32 UIMM8;
OPCODE ROL1
0xD0 /0 NO RM8
0xD1 /0 *NO RM16
0xD1 /0 %NO RM32;
OPCODE ROR
0xD2 /1 NO RM8 CL
0xD3 /1 *NO RM16 CL
0xD3 /1 %NO RM32 CL
0xC0 /1 IB RM8 UIMM8
0xC1 /1 *IB RM16 UIMM8
0xC1 /1 %IB RM32 UIMM8;
OPCODE ROR1
0xD0 /1 NO RM8
0xD1 /1 *NO RM16
0xD1 /1 %NO RM32;
OPCODE SAL
0xD2 /4 NO RM8 CL
0xD3 /4 *NO RM16 CL
0xD3 /4 %NO RM32 CL
0xC0 /4 IB RM8 UIMM8
0xC1 /4 *IB RM16 UIMM8
0xC1 /4 %IB RM32 UIMM8;
OPCODE SAL1
0xD0 /4 NO RM8
0xD1 /4 *NO RM16
0xD1 /4 %NO RM32;
OPCODE SAR
0xD2 /7 NO RM8 CL
0xD3 /7 *NO RM16 CL
0xD3 /7 %NO RM32 CL
0xC0 /7 IB RM8 UIMM8
0xC1 /7 *IB RM16 UIMM8
0xC1 /7 %IB RM32 UIMM8;
OPCODE SAR1
0xD0 /7 NO RM8
0xD1 /7 *NO RM16
0xD1 /7 %NO RM32;
OPCODE SHL
0xD2 /4 NO RM8 CL
0xD3 /4 *NO RM16 CL
0xD3 /4 %NO RM32 CL
0xC0 /4 IB RM8 UIMM8
0xC1 /4 *IB RM16 UIMM8
0xC1 /4 %IB RM32 UIMM8;
OPCODE SHL1
0xD0 /4 NO RM8
0xD1 /4 *NO RM16
0xD1 /4 %NO RM32;
OPCODE SHR
0xD2 /5 NO RM8 CL
0xD3 /5 *NO RM16 CL
0xD3 /5 %NO RM32 CL
0xC0 /5 IB RM8 UIMM8
0xC1 /5 *IB RM16 UIMM8
0xC1 /5 %IB RM32 UIMM8;
OPCODE SHR1
0xD0 /5 NO RM8
0xD1 /5 *NO RM16
0xD1 /5 %NO RM32;
OPCODE FILD
0xDF /5 NO RM32; //Load 64 bit I4
OPCODE FISTP
0xDF /7 NO RM32; //Store 64 bit I4
OPCODE FLD
0xDD /0 NO RM32; //Load 64 bit double
OPCODE FSTP
0xDD /3 NO RM32; //Store 64 bit double
OPCODE FST
0xDD /2 NO RM32; //Store 64 bit double
OPCODE FRSTOR
0xDD /4 NO RM32;
OPCODE FSAVE
0x9B 0xDD /6 NO RM32;
OPCODE FYL2X 0xD9 0xF1 NO;
OPCODE FYL2XP1 0xD9 0xF9 NO;
OPCODE F2XM1 0xD9 0xF0 NO;
OPCODE FABS 0xD9 0xE1 NO;
OPCODE FCHS 0xD9 0xE0 NO;
OPCODE FSIN 0xD9 0xFE NO;
OPCODE FCOS 0xD9 0xFF NO;
OPCODE FPTAN 0xD9 0xF2 NO;
OPCODE FPATAN 0xD9 0xF3 NO;
OPCODE FSQRT 0xD9 0xFA NO;
OPCODE FMULP 0xDE 0xC9 NO;
OPCODE FDIVP 0xDE 0xF9 NO;
OPCODE FDIVRP 0xDE 0xF1 NO;
OPCODE FPREM 0xD9 0xF8 NO;
OPCODE FADDP 0xDE 0xC1 NO;
OPCODE FSUBP 0xDE 0xE9 NO;
OPCODE FSUBRP 0xDE 0xE1 NO;
OPCODE FCOMIP 0xDF 0xF1 NO;
OPCODE FCLEX 0x9B 0xDB 0xE2 NO;
OPCODE FSTSW 0x98 0xDF 0xE0 NO;
OPCODE FDECSTP 0xD9 0xF6 NO;
OPCODE FINCSTP 0xD9 0xF7 NO;
OPCODE FFREE 0xDD 0xC0 NO;
OPCODE FRNDINT 0xD9 0xFC NO;
OPCODE FSCALE 0xD9 0xFD NO;
OPCODE FXTRACT 0xD9 0xF4 NO;
OPCODE FLD1 0xD9 0xE8 NO;
OPCODE FLDL2T 0xD9 0xE9 NO;
OPCODE FLDL2E 0xD9 0xEA NO;
OPCODE FLDPI 0xD9 0xEB NO;
OPCODE FLDLG2 0xD9 0xEC NO;
OPCODE FLDLN2 0xD9 0xED NO;
OPCODE FLDZ 0xD9 0xEE NO;
OPCODE FXCH 0xD9 0xC9 NO;
OPCODE FSTCW 0x9B 0xD9 /7 NO RM32;
OPCODE FLDCW 0xD9 /5 NO RM32;
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1126
View File
File diff suppressed because it is too large. Load diff
+4083
View File
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
Binary file not shown.
+1687
View File
File diff suppressed because it is too large. Load diff
Binary file not shown.
+3045
View File
File diff suppressed because it is too large. Load diff
+773
View File
@@ -0,0 +1,773 @@
/*
void PrsPush(ParseStack *ps,U4 val)
{
ps->stk[ps->ptr++]=val;
}
U8 PrsPop(ParseStack *ps)
{
return ps->stk[--ps->ptr];
}
*/
LTextern CP_PRSPUSH void PrsPush(ParseStack *ps,U4 val);
LTextern CP_PRSPOP U4 PrsPop(ParseStack *ps);
#define PRST_UNARY_TERM 0
#define PRST_UNARY_MODIFIERS 1
#define PRST_DEREFERRENCE 2
#define PRST_CHECK_BINARY_OPS 3
BoolU4 PrsParseExpression(LexStruct *l,BoolU4 add_esp=FALSE)
{
BoolU4 result=TRUE,question_clause=FALSE,
cont_unary,cont_check_binary_ops,is_lower;
I8 i,j,k;
IntermediateCode *tempi,*tempi_first=l->cb.cb_out_ptr;
ClassStruct *tempc;
ParseStack *ps=MAlloc(sizeof(ParseStack));
ps->ptr=0;
PrsPush(ps,0); //terminate
PrsPush(ps,0); //terminate
try {
do {
l->flags&=~(LF_PREINC+LF_PREDEC+LF_POSTINC+LF_POSTDEC+LF_FUNCTION);
do i=PrsUnaryTerm(l,ps);
while (i==PRST_UNARY_TERM);
while (i==PRST_UNARY_MODIFIERS)
i=PrsUnaryModifier(l,ps);
if (i==PRST_DEREFERRENCE)
PrsDereferrence(l,ps);
//Check for binary Ops
do {
i=PrsPop(ps);
tempc=PrsPop(ps);
if (i && i.u2[1]<=1) {
tempi=l->cb.cb_last_out_ptr;
i&=0xFFFF;
tempc=tempi->ic_class;
if (Bt(deref_bitmap,i) && tempc->pointer_cnt) {
tempc=tempc-sizeof(ClassStruct);
while (tempc->return_class)
tempc=tempc->return_class;
if (tempc->type & HTT_INTERNAL_TYPE)
i=EC_DEREF_U8+0x10000+it_to_ec_offset[tempc->sub_type];
else
i=EC_DEREF_U4+0x10000;
} else {
if (i==EC_ADDRESS) {
if (!(l->flags & (LF_EAX|LF_ARRAY))) {
j=tempi->ic_code.u2[0];
if (!Bt(deref_bitmap,j))
PrsExcept(l,"ST_INVALID_LVALUE");
tempi->ic_code=EC_NOP;
tempc=tempc+sizeof(ClassStruct);
}
}
}
CbAddIc(l,i,0,tempc);
cont_check_binary_ops=TRUE;
} else {
PrsPush(ps,tempc);
PrsPush(ps,i);
i=l->token;
k=binary_ops_table[i];
if (k.u2[0]==EC_QUESTION)
question_clause=TRUE;
else if (k.u2[0]==EC_COLON) {
if (!question_clause)
k=0;
else
question_clause=FALSE;
}
if (!k.u2[1]) {
cont_check_binary_ops=FALSE;
cont_unary=FALSE; //DONE
} else {
Lex(l); //skip op
if (Bt(assign_bitmap,k.u2[0])) {
tempi=l->cb.cb_last_out_ptr;
tempc=tempi->ic_class;
j=tempi->ic_code.u2[0];
if (!Bt(deref_bitmap,j))
PrsExcept(l,"ST_INVALID_LVALUE");
tempi->ic_code=EC_NOP;
while (tempc->return_class)
tempc=tempc->return_class;
if (!(tempc->type & HTT_INTERNAL_TYPE))
k=k.u2[0]+0x100000+it_to_ec_offset[IT_U4];
else
k=k.u2[0]+0x100000+it_to_ec_offset[tempc->sub_type];
}
do {
i=PrsPop(ps); //pop ops of higher prec
tempc=PrsPop(ps);
is_lower=FALSE;
if (i) {
if (k.u2[1]==i.u2[1]) {
if (!Bt(assign_bitmap,k.u2[0]) ||
!Bt(assign_bitmap,i.u2[0]))
is_lower=TRUE;
} else if (k.u2[1]>i.u2[1])
is_lower=TRUE;
}
if (is_lower)
CbAddIc(l,i,0,tempc);
else {
PrsPush(ps,tempc);
PrsPush(ps,i);
tempi=l->cb.cb_last_out_ptr;
tempc=tempi->ic_class;
PrsPush(ps,tempc);
PrsPush(ps,k);
cont_check_binary_ops=FALSE;
cont_unary=TRUE;
break;
}
} while (TRUE);
}
}
} while (cont_check_binary_ops);
} while (cont_unary);
while (TRUE) {
i=PrsPop(ps);
tempc=PrsPop(ps);
if (i)
CbAddIc(l,i,0,tempc);
else
break;
}
} catch {
if (Fs->except_argc>0) {
if (Fs->except_argv[0]==EXCEPT_COMPILER) {
l->statement_cnt=0;
l->braces_cnt=0;
result=FALSE;
Fs->catch_except=TRUE;
}
}
}
Free(ps);
if (add_esp && result) {
if (Bt(push_bitmap,tempi_first->ic_code.u2[0])) {
tempi_first->ic_flags|=ICF_NO_PUSHES;
CbAddIc(l,EC_END_EXP,0,0);
} else
CbAddIc(l,EC_ADD_ESP32,8,0);
}
return result;
}
U8 PrsUnaryTerm(LexStruct *l,ParseStack *ps)
{
I8 i,*i_ptr;
I8 argc_cnt,size;
U8 d;
SysHashEntry *temph,**temph1;
ClassStruct *tempc,*tempc1,*tempc2;
GlblVarStruct *tempg;
MemberListStruct *tempm;
LexUndefEntry *templu;
CbMiscStruct *tempmc;
IntermediateCode *tempi;
BoolU4 needs_right_paren;
LexCbStack *templ,*templ1;
if (l->token==TK_INTEGER) {
if (l->cur_i<0)
CbAddIc(l,EC_U8,l->cur_i,sys_internal_types[IT_U8]);
else
CbAddIc(l,EC_U8,l->cur_i,sys_internal_types[IT_I8]);
Lex(l);
return PRST_CHECK_BINARY_OPS;
}
if (l->token==TK_DOUBLE) {
i_ptr=&l->cur_d;
CbAddIc(l,EC_DOUBLE,*i_ptr,sys_internal_types[IT_DOUBLE]);
Lex(l);
return PRST_CHECK_BINARY_OPS;
}
if (l->token==TK_STRING) {
d=LexExtendString(l,&size);
if (l->flags & LF_ASM_EXPRESSIONS)
CbAddIc(l,EC_U8,d,sys_internal_types[IT_I1]+sizeof(ClassStruct));
else {
tempmc=CbMiscNew(l,CBMT_STRING_CONSTANT);
CbAddIc(l,EC_STRING_CONSTANT,tempmc,sys_internal_types[IT_I1]+sizeof(ClassStruct));
tempmc->st_len=size;
tempmc->string=d;
l->flags|=LF_HAS_MISC_DATA;
}
return PRST_CHECK_BINARY_OPS;
}
if (l->token==TK_INSERT_BINARY) {
d=l->ident;
size=l->ident_len;
l->ident=NULL;
Lex(l);
if (l->flags & LF_ASM_EXPRESSIONS)
CbAddIc(l,EC_U8,d,sys_internal_types[IT_I1]+sizeof(ClassStruct));
else {
tempmc=CbMiscNew(l,CBMT_STRING_CONSTANT);
CbAddIc(l,EC_STRING_CONSTANT,tempmc,sys_internal_types[IT_I1]+sizeof(ClassStruct));
tempmc->st_len=size;
tempmc->string=d;
l->flags|=LF_HAS_MISC_DATA;
}
return PRST_CHECK_BINARY_OPS;
}
if (l->token==TK_INSERT_BINARY_TYPE ||
l->token==TK_INSERT_BINARY_SIZE) {
CbAddIc(l,EC_U8,l->cur_i,sys_internal_types[IT_U8]);
Lex(l);
return PRST_CHECK_BINARY_OPS;
}
if (l->token=='(') {
Lex(l); //Skip (
if (!PrsParseExpression(l))
throw(EXCEPT_COMPILER,2);
if (l->token!=')')
PrsExcept(l,"ST_MISSING_RIGHT_PAREN");
Lex(l); //skip )
l->flags=(l->flags & ~(LF_ARRAY+LF_FUNCTION)) | LF_EAX;
return PRST_UNARY_MODIFIERS;
}
i=unary_ops_table[l->token];
if (i.u2[1]) {
Lex(l); //Skip op
if (i.u2[0]==EC_ADDRESS && l->token==TK_IDENT) {
if (tempc=l->hash_entry) {
if (tempc->type & HTT_FUNCTION) {
if (!Bt(&tempc->flags,Cf_INTERNAL)) {
Lex(l); //skip fun name
if (Bt(&tempc->flags,Cf_EXTERN)) {
if (l->a)
CbAddIc(l,EC_ABSOLUTE_ADDRESS,
tempc->executable_address,sys_internal_types[IT_U4]);
else
CbAddIc(l,EC_U8,
&tempc->executable_address,sys_internal_types[IT_U4]);
CbAddIc(l,EC_DEREF_U4,0,
sys_internal_types[IT_U4]);
} else {
if (l->a)
CbAddIc(l,EC_ABSOLUTE_ADDRESS,
tempc->executable_address,sys_internal_types[IT_U4]);
else
CbAddIc(l,EC_U8,
tempc->executable_address,sys_internal_types[IT_U4]);
}
return PRST_CHECK_BINARY_OPS;
} //TODO: is this an error?
}//TODO: is this an error?
}//TODO: is this an error?
}
PrsPush(ps,tempc);
PrsPush(ps,i);
return PRST_UNARY_TERM;
}
if (l->token=='+') {
Lex(l);
return PRST_UNARY_TERM;
}
if (l->token!=TK_IDENT) {
if (l->token==TK_PLUS_PLUS) {
Lex(l);
l->flags|=LF_PREINC;
return PRST_UNARY_TERM;
}
if (l->token==TK_MINUS_MINUS) {
Lex(l);
l->flags|=LF_PREDEC;
return PRST_UNARY_TERM;
}
if (l->token=='$$' && l->flags & LF_ASM_EXPRESSIONS) {
Lex(l);
CbAddIc(l,EC_U8,l->instruction_pointer,sys_internal_types[IT_U4]);
return PRST_CHECK_BINARY_OPS;
}
PrsExcept(l,"ST_MISSING_EXPRESSION");
}
if (tempm=l->local_var_entry) {
l->flags&=~(LF_EAX+LF_ARRAY+LF_FUNCTION);
tempc=tempm->member_class+sizeof(ClassStruct);
if (tempm->flags & MLF_FUNCTION) {
l->flags|=LF_FUNCTION;
PrsPush(ps,0);
PrsPush(ps,tempm->parameter_cnt);
}
if (tempm->cnt) {
l->flags|=LF_ARRAY;
tempc+=sizeof(ClassStruct);
}
CbAddIc(l,EC_EBP,0,tempc);
CbAddIc(l,EC_U8,tempm->offset,tempc);
CbAddIc(l,EC_ADDITION,0,tempc);
Lex(l); //skip var name
return PRST_UNARY_MODIFIERS;
}
if (!(temph=l->hash_entry)) {
if (!(l->flags & LF_ASM_EXPRESSIONS))
PrsExcept(l,"ST_INVALID_LVALUE");
temph=MAllocZ(sizeof(SysHashEntry));
temph->string=l->ident;
l->ident=NULL;
if (temph->string[0]=='@' &&
temph->string[1]=='@') {
temph->type=HTT_SYS_SYMBOL | HTT_UNRESOLVED_LOCAL;
temph1=FindHashBucket(temph->string,l->local_hash_table);
} else {
temph->type=HTT_SYS_SYMBOL | HTT_UNRESOLVED_GLBL;
temph1=FindHashBucket(temph->string,l->glbl_hash_table);
}
temph->use_cnt=0;
SetSourceFileInfo(l,temph);
temph->next=*temph1;
*temph1=temph;
temph->user0=0;
}
if (temph->type & HTT_SYS_SYMBOL) {
if (!(temph->type & HTT_LITERAL) &&
!(temph->type & HTT_IMPORT))
l->absolute_address_cnt++;
if (temph->type & (HTT_UNRESOLVED_LOCAL|HTT_UNRESOLVED_GLBL)) {
templu=MAlloc(sizeof(LexUndefEntry));
templu->hash=temph;
templu->next=l->undef_hash_entry;
l->undef_hash_entry=templu;
if (temph->type & HTT_UNRESOLVED_LOCAL)
l->flags|=LF_UNRESOLVED_LOCAL;
else
l->flags|=LF_UNRESOLVED_GLBL;
CbAddIc(l,EC_U8,&temph->user0,sys_internal_types[IT_U4]);
CbAddIc(l,EC_DEREF_U4,0,sys_internal_types[IT_U4]);
} else {
if (l->a && !(temph->type & HTT_LITERAL))
CbAddIc(l,EC_ABSOLUTE_ADDRESS,temph->user0,sys_internal_types[IT_U4]);
else
CbAddIc(l,EC_U8,temph->user0,sys_internal_types[IT_U4]);
}
Lex(l);
return PRST_CHECK_BINARY_OPS;
}
if (temph->type & HTT_FUNCTION) {
Lex(l); //skip fun name
CbPush(l);
templ=l->cb.cb_next;
l->cb.cb_next=NULL;
tempc=temph;
i=tempc->parameter_cnt;
tempm=tempc->member_list;
argc_cnt=0;
if (l->token!='(')
needs_right_paren=FALSE;
else {
Lex(l);
needs_right_paren=TRUE;
}
while (i--) {
if (l->token==',')
Lex(l);
CbInitOutPtrs(&l->cb);
if (tempm->flags & MLF_DEFAULT_AVAILABLE &&
(l->token==')' || !needs_right_paren))
CbAddIc(l,EC_U8,tempm->default_value,tempm->member_class);
else
if (!PrsParseExpression(l))
throw(EXCEPT_COMPILER,3);
else {
CbPush(l);
CbAddIc(l,0,0,0);
tempi=CmpOptPass1(l,NULL,FALSE);
CbPop(l);
tempc1=tempi->ic_class;
while (tempc1->return_class)
tempc1=tempc1->return_class;
tempc2=tempm->member_class;
while (tempc2->return_class)
tempc2=tempc2->return_class;
if (tempc2->sub_type==IT_DOUBLE &&
tempc1->sub_type!=IT_DOUBLE)
tempi->ic_flags|=ICF_TO_DOUBLE;
else
if (tempc2->sub_type!=IT_DOUBLE &&
tempc1->sub_type==IT_DOUBLE)
tempi->ic_flags|=ICF_TO_INT;
}
CbAddIc(l,0,0,0);
CbPush(l);
tempm=tempm->next;
}
if (tempm && tempm->flags & MLF_DOT_DOT_DOT) {
CbInitOutPtrs(&l->cb);
CbAddIc(l,EC_U8,0,tempm->member_class);
tempi=l->cb.cb_last_out_ptr;
CbAddIc(l,0,0,0);
CbPush(l);
if (needs_right_paren) {
if (l->token!=')') {
do {
if (l->token==',')
Lex(l);
CbInitOutPtrs(&l->cb);
if (!PrsParseExpression(l))
throw(EXCEPT_COMPILER,4);
CbAddIc(l,0,0,0);
CbPush(l);
argc_cnt++;
} while (l->token==',');
}
}
tempi->ic_data=argc_cnt++; //++ so add_esp latter works
}
if (needs_right_paren) {
if (l->token!=')')
PrsExcept(l,"ST_MISSING_RIGHT_PAREN");
Lex(l);
}
templ1=templ->cb_next;
templ->cb_next=l->cb.cb_next;
l->cb.cb_next=templ;
CbPop(l);
templ=l->cb.cb_next;
l->cb.cb_next=templ1;
while (templ) {
templ1=templ->cb_next;
CbAppend(l,templ);
templ=templ1;
}
if (Bt(&tempc->flags,Cf_INTERNAL))
CbAddIc(l,tempc->executable_address,0,tempc->return_class);
else if (Bt(&tempc->flags,Cf_EXTERN)) {
if (l->a)
CbAddIc(l,EC_CALL_INDIRECT2,tempc->executable_address,tempc->return_class);
else
CbAddIc(l,EC_CALL_INDIRECT2,&tempc->executable_address,tempc->return_class);
CbAddIc(l,EC_ADD_ESP32,(argc_cnt+tempc->parameter_cnt)<<3,tempc->return_class);
} else {
CbAddIc(l,EC_CALL,tempc->executable_address,tempc->return_class);
CbAddIc(l,EC_ADD_ESP32,(argc_cnt+tempc->parameter_cnt)<<3,tempc->return_class);
}
l->flags=(l->flags|LF_EAX) & ~(LF_ARRAY|LF_FUNCTION);
return PRST_UNARY_MODIFIERS;
}
if (temph->type & HTT_GLBL_VAR) {
tempg=temph;
tempc=tempg->var_class+sizeof(ClassStruct);
l->flags&=~(LF_EAX|LF_ARRAY|LF_FUNCTION);
if (tempg->cnt) {
tempc+=sizeof(ClassStruct);
l->flags|=LF_ARRAY;
}
if (tempg->flags & GVAF_FUNCTION) {
//TODO:Not implemented
l->flags|=LF_FUNCTION;
}
if (l->a) {
if (tempg->flags & GVAF_EXTERN) { //TODO: Untested
CbAddIc(l,EC_U8,&tempg->data_address,tempc);
CbAddIc(l,EC_DEREF_U4,0,tempc);
} else {
CbAddIc(l,EC_ABSOLUTE_ADDRESS,tempg->data_address,tempc);
if (tempg->flags & GVAF_IMPORT)
CbAddIc(l,EC_DEREF_U4,0,tempc);
}
} else {
if (tempg->flags & GVAF_EXTERN) {
CbAddIc(l,EC_U8,&tempg->data_address,tempc);
CbAddIc(l,EC_DEREF_U4,0,tempc);
} else
CbAddIc(l,EC_U8,tempg->data_address,tempc);
}
Lex(l);
return PRST_UNARY_MODIFIERS;
}
if (!(temph->type & HTT_KEYWORD))
PrsExcept(l,"ST_MISSING_EXPRESSION");
if (temph->user0==KW_SIZEOF) {
if (Lex(l)!='(') PrsExcept(l,"ST_EXPECTING_LEFT_PAREN");
if (Lex(l)!=TK_IDENT)
PrsExcept(l,"ST_INVALID_CLASS");
if (tempm=l->local_var_entry) {
tempc=tempm->member_class;
i=(tempm->cnt) ? tempm->cnt:1;
CbAddIc(l,EC_U8,tempc->size*i,sys_internal_types[IT_U4]);
} else {
tempc=l->hash_entry;
if (!tempc || !(tempc->type & (HTT_CLASS|HTT_INTERNAL_TYPE|HTT_GLBL_VAR)))
PrsExcept(l,"ST_INVALID_CLASS");
CbAddIc(l,EC_U8,tempc->size,sys_internal_types[IT_U4]);
} //TODO: should allow '*' and '.member', etc;
if (Lex(l)!=')')
PrsExcept(l,"ST_MISSING_RIGHT_PAREN");
Lex(l);
return PRST_CHECK_BINARY_OPS;
} else if (temph->user0==KW_OFFSET) {
if (Lex(l)!='(') PrsExcept(l,"ST_EXPECTING_LEFT_PAREN");
if (Lex(l)!=TK_IDENT)
PrsExcept(l,"ST_INVALID_CLASS");
if (tempm=l->local_var_entry)
tempc=tempm->member_class;
else {
tempc=l->hash_entry;
if (!tempc || !(tempc->type & (HTT_CLASS|HTT_GLBL_VAR)))
PrsExcept(l,"ST_INVALID_CLASS");
else if (tempc->type & HTT_GLBL_VAR) {
tempg=tempc;
tempc=tempg->var_class;
}
}
if (Lex(l)!='.')
PrsExcept(l,"ST_EXPECTING_DOT");
if (Lex(l)!=TK_IDENT)
PrsExcept(l,"ST_INVALID_MEMBER");
if (!(tempm=FindMember(l->ident,tempc)))
PrsExcept(l,"ST_INVALID_MEMBER");
CbAddIc(l,EC_U8,tempm->offset,sys_internal_types[IT_U4]);
if (Lex(l)!=')')
PrsExcept(l,"ST_MISSING_RIGHT_PAREN");
Lex(l);
return PRST_CHECK_BINARY_OPS;
}
PrsExcept(l,"ST_MISSING_EXPRESSION");
}
U8 PrsUnaryModifier(LexStruct *l,ParseStack *ps)
{
I8 i,j;
LexCbStack *templ,*templ2,*templl;
ClassStruct *tempc,*tempc1;
MemberListStruct *tempm;
IntermediateCode *tempi;
if (l->flags & LF_ASM_EXPRESSIONS)
return PRST_CHECK_BINARY_OPS;
if (l->token==TK_DEREFERRENCE) {
tempi=l->cb.cb_last_out_ptr;
if (!(l->flags & (LF_EAX | LF_ARRAY))) {
tempc=tempi->ic_class-sizeof(ClassStruct);
CbAddIc(l,EC_DEREF_U4+0x10000,0,tempc);
} else
tempi->ic_class-=sizeof(ClassStruct);
}
if (l->token=='.' || l->token==TK_DEREFERRENCE) {
tempi=l->cb.cb_last_out_ptr;
tempc=tempi->ic_class;
if (!(l->flags & LF_EAX))
tempc-=sizeof(ClassStruct);
if (!(tempc->type & HTT_CLASS))
PrsExcept(l,"ST_INVALID_CLASS");
if (Lex(l)!=TK_IDENT)
PrsExcept(l,"ST_INVALID_MEMBER");
if (!(tempm=FindMember(l->ident,tempc)))
PrsExcept(l,"ST_INVALID_MEMBER");
Lex(l); //skip member name
tempc1=tempm->member_class+sizeof(ClassStruct);
CbAddIc(l,EC_U8,tempm->offset,tempc1);
l->flags&=~(LF_EAX|LF_ARRAY|LF_FUNCTION);
if (tempm->cnt) {
tempc1+=sizeof(ClassStruct);
l->flags|=LF_ARRAY;
}
if(tempm->flags & MLF_FUNCTION) {
PrsPush(ps,0);
PrsPush(ps,tempm->parameter_cnt);
l->flags|=LF_FUNCTION;
}
CbAddIc(l,EC_ADDITION,0,tempc1);
return PRST_UNARY_MODIFIERS;
}
if (l->token==TK_CAST) {
if (Lex(l)!='(')
PrsExcept(l,"ST_EXPECTING_LEFT_PAREN");
if (Lex(l)!=TK_IDENT)
PrsExcept(l,"ST_INVALID_CLASS");
tempc=l->hash_entry;
if (!tempc || !(tempc->type & (HTT_CLASS|HTT_INTERNAL_TYPE)))
PrsExcept(l,"ST_INVALID_CLASS");
while (Lex(l)=='*')
tempc+=sizeof(ClassStruct);
tempc+=sizeof(ClassStruct);
tempi=l->cb.cb_last_out_ptr;
tempi->ic_class=tempc;
if (l->token!=')')
PrsExcept(l,"ST_MISSING_RIGHT_PAREN");
Lex(l);
return PRST_UNARY_MODIFIERS;
}
if (l->token=='[') {
Lex(l);
tempi=l->cb.cb_last_out_ptr;
if (!(l->flags & (LF_ARRAY | LF_EAX))) {
tempc=tempi->ic_class-sizeof(ClassStruct);
while (!(tempc->type & HTT_INTERNAL_TYPE) && tempc->return_class)
tempc=tempc->return_class;
if (tempc->type==HTT_INTERNAL_TYPE)
i=EC_DEREF_U8+0x10000+it_to_ec_offset[tempc->sub_type];
else
i=EC_DEREF_U4+0x10000;
CbAddIc(l,i,0,tempc);
} else {
tempc=tempi->ic_class;
if (!(l->flags & LF_EAX))
tempc-=sizeof(ClassStruct);
}
tempc1=tempc-sizeof(ClassStruct);
CbAddIc(l,EC_U8,tempc1->size,tempc);
if (!PrsParseExpression(l))
throw(EXCEPT_COMPILER,5);
if (l->token!=']')
PrsExcept(l,"ST_MISSING_RIGHT_BRACKET");
Lex(l); //skip ]
CbAddIc(l,EC_MULTIPLICATION,0,tempc);
CbAddIc(l,EC_ADDITION,0,tempc);
l->flags&=~(LF_EAX|LF_ARRAY);
return PRST_UNARY_MODIFIERS;
}
if (l->token=='(' && l->flags & LF_FUNCTION) {
tempi=l->cb.cb_last_out_ptr;
if (!(l->flags & (LF_EAX | LF_ARRAY))) {
tempc=tempi->ic_class-sizeof(ClassStruct);
CbAddIc(l,EC_DEREF_U4+0x10000,0,tempc);
} else {
tempi->ic_class=tempi->ic_class-sizeof(ClassStruct);
tempc=tempi;
}
i=PrsPop(ps);
PrsPop(ps);
j=i;
Lex(l); //skip '('
CbPush(l);
templ=l->cb.cb_next;
l->cb.cb_next=NULL;
while (i--) {
if (l->token==',')
Lex(l);
CbInitOutPtrs(&l->cb);
if (!PrsParseExpression(l))
throw(EXCEPT_COMPILER,6);
CbAddIc(l,0,0,0);
CbPush(l);
}
if (l->token!=')')
PrsExcept(l,"ST_MISSING_RIGHT_PAREN");
Lex(l); //skip ')'
templl=templ->cb_next;
templ->cb_next=l->cb.cb_next;
l->cb.cb_next=templ;
CbPop(l);
templ=l->cb.cb_next;
l->cb.cb_next=templl;
while (templ) {
templ2=templ->cb_next;
CbAppend(l,templ);
templ=templ2;
}
CbAddIc(l,EC_CALL_INDIRECT,j<<3,tempc);
CbAddIc(l,EC_ADD_ESP32,j<<3+8,tempc);
l->flags=(l->flags | LF_EAX)&~(LF_ARRAY | LF_FUNCTION);
return PRST_UNARY_MODIFIERS;
}
if (l->token==TK_PLUS_PLUS) {
Lex(l);
l->flags|=LF_POSTINC;
return PRST_DEREFERRENCE;
}
if (l->token==TK_MINUS_MINUS) {
Lex(l);
l->flags|=LF_POSTDEC;
return PRST_DEREFERRENCE;
}
return PRST_DEREFERRENCE;
}
U8 PrsDereferrence(LexStruct *l,ParseStack *ps)
{
I8 i;
ClassStruct *tempc;
IntermediateCode *tempi;
if (l->flags & LF_FUNCTION) {
i=PrsPop(ps);
tempc=PrsPop(ps);
}
if (l->flags & LF_EAX)
return PRST_CHECK_BINARY_OPS;
tempi=l->cb.cb_last_out_ptr;
tempc=tempi->ic_class-sizeof(ClassStruct);
if (l->flags & LF_ARRAY) {
tempi->ic_class=tempc;
return PRST_CHECK_BINARY_OPS;
}
if (l->flags & LF_PREINC) {
l->flags&=~LF_PREINC;
i=EC_PP_U8;
} else if (l->flags & LF_PREDEC) {
l->flags&=~LF_PREDEC;
i=EC_MM_U8;
} else if (l->flags & LF_POSTINC) {
l->flags&=~LF_POSTINC;
i=EC_U8_PP;
} else if (l->flags & LF_POSTDEC) {
l->flags&=~LF_POSTDEC;
i=EC_U8_MM;
} else
i=EC_DEREF_U8;
while (tempc->return_class)
tempc=tempc->return_class;
if (tempc->type & HTT_INTERNAL_TYPE)
i+=it_to_ec_offset[tempc->sub_type];
else
i+=it_to_ec_offset[IT_U4];
CbAddIc(l,i+0x10000,0,tempc);
return PRST_CHECK_BINARY_OPS;
}
U1 *CompileExpression(LexStruct *l)
{
U1 *result;
U8 size;
DbgInfo *dbg=NULL;
CbPush(l);
CbInitOutPtrs(&l->cb);
if (PrsParseExpression(l,TRUE)) {
CbAddIc(l,EC_RET,0,0);
CbAddIc(l,0,0,0);
result=CbCompile(l,NULL,&size,&dbg);
} else
result=NULL;
CbPop(l);
Free(dbg);
return result;
}
BoolU4 GetExpression(LexStruct *l,U1 **e) //FALSE=no err
{
*e=CompileExpression(l);
if (*e)
return TRUE;
else
return FALSE;
}
I8 Expression(LexStruct *l) //FALSE=no err
{
I8 result;
U1 *e=CompileExpression(l);
if (e) {
result=Run(e);
DelExpression(e);
} else
result=0;
return result;
}
+759
View File
@@ -0,0 +1,759 @@
void OutChar(I1 **addr_dst,I1 ch,I1 **addr_buf)
{
I8 i;
I1 *dst=*addr_dst,*buf;
if (addr_buf) {
buf=*addr_buf;
i=dst-buf;
if (i>=MSize(buf)) {
buf=MAlloc(i<<1+1);
MemCpy(buf,*addr_buf,i);
dst=buf+i;
*addr_buf=buf;
}
}
*dst++=ch;
*addr_dst=dst;
}
void OutString(I1 *ptr,I1 **addr_buf,I1 *addr_dst,
I8 len,BoolU4 left_justify,BoolU4 truncate)
{
I8 i,j;
i=StrLen(ptr);
if (truncate && i>len)
i=len;
if (left_justify) {
for (j=0;j<i;j++)
OutChar(addr_dst,*(ptr++),addr_buf);
for (j=0;j<len-i;j++)
OutChar(addr_dst,CH_SPACE,addr_buf);
} else {
for (j=0;j<len-i;j++)
OutChar(addr_dst,CH_SPACE,addr_buf);
for (j=len-i;j<len;j++)
OutChar(addr_dst,*(ptr++),addr_buf);
}
}
I1 *MSPrintFPSect(U8 add,U8 field_length)
{
U8 offset;
SysHashEntry *temph;
if (temph=FindPSect(add,&offset)) {
if (offset<=0xFFFF) {
if (field_length>5)
return MSPrintF("%*ts,%04X",field_length-5,temph->string,offset);
else
return MSPrintF("%s,%04X",temph->string,offset);
}
}
if (field_length)
return MSPrintF("%*tX",field_length,add);
else
return MSPrintF("%X",add);
}
I1 *MSPrintFTime(LTDate ltdt,U8 sub_format)
{
LTDateStruct d;
ToLTDateStruct(&d,ltdt);
switch (sub_format) {
case 1:
return MSPrintF("%02d:%02d",d.hours,d.minutes);
case 2:
if (d.hours>=12)
return MSPrintF("%02d:%02d:%02d pm",d.hours-12,d.minutes,d.seconds);
else
return MSPrintF("%02d:%02d:%02d am",d.hours,d.minutes,d.seconds);
case 3:
if (d.hours>=12)
return MSPrintF("%02d:%02d pm",d.hours-12,d.minutes);
else
return MSPrintF("%02d:%02d am",d.hours,d.minutes);
case 4:
if (d.hours>=12)
return MSPrintF("%02d:%02d:%02dp",d.hours-12,d.minutes,d.seconds);
else
return MSPrintF("%02d:%02d:%02da",d.hours,d.minutes,d.seconds);
case 5:
if (d.hours>=12)
return MSPrintF("%02d:%02dp",d.hours-12,d.minutes);
else
return MSPrintF("%02d:%02da",d.hours,d.minutes);
case 6:
return MSPrintF("%dh %02dm",d.hours+ltdt.date*24,d.minutes);
case 7:
return MSPrintF("%dh %02dm %02ds",d.hours+ltdt.date*24,d.minutes,d.seconds);
case 8:
return MSPrintF("%dd %02dh %02dm",ltdt.date,d.hours,d.minutes);
case 9:
return MSPrintF("%dd %02dh %02dm %02ds",ltdt.date,d.hours,d.minutes,d.seconds);
case 10:
return MSPrintF("%dd %02dh %02dm %02d.%02ds",ltdt.date,d.hours,d.minutes,d.seconds,d.hundredths);
case 11:
return MSPrintF("%dh %02dm %02d.%02ds",d.hours+ltdt.date*24,d.minutes,d.seconds,d.hundredths);
case 12:
return MSPrintF("%d.%02d",MulU8(60,(ltdt.date*24+d.hours)*60+d.minutes)+d.seconds,d.hundredths);
case 13:
return MSPrintF("%02d:%02d.%02d",MulU8(60,ltdt.date*24+d.hours)+d.minutes,d.seconds,d.hundredths);
case 14:
return MSPrintF("%02d:%02d:%02d.%02d",ltdt.date*24+d.hours,d.minutes,d.seconds,d.hundredths);
case 15:
return MSPrintF("%dd %02dh %02dm %02d.%04ds",ltdt.date,d.hours,d.minutes,d.seconds,d.ten_thousandths);
case 16:
return MSPrintF("%dh %02dm %02d.%04ds",d.hours+ltdt.date*24,d.minutes,d.seconds,d.ten_thousandths);
case 17:
return MSPrintF("%d.%04d",MulU8(60,(ltdt.date*24+d.hours)*60+d.minutes)+d.seconds,d.ten_thousandths);
case 18:
return MSPrintF("%02d:%02d.%04d",MulU8(60,ltdt.date*24+d.hours)+d.minutes,d.seconds,d.ten_thousandths);
case 19:
return MSPrintF("%02d:%02d:%02d.%04d",ltdt.date*24+d.hours,d.minutes,d.seconds,d.ten_thousandths);
default:
return MSPrintF("%02d:%02d:%02d",d.hours,d.minutes,d.seconds);
}
}
I1 *MSPrintFDate(U8 dt,U8 sub_format)
{
LTDateStruct d;
LTDate ltdt=0;
ltdt.date=dt;
ToLTDateStruct(&d,ltdt);
switch (sub_format) {
case 1:
return MSPrintF("%02d/%02d",d.month,d.day_of_month);
case 2:
return MSPrintF("%3tZ %02d/%02d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.month,d.day_of_month);
case 3:
return MSPrintF("%3tZ %02d/%02d/%02d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.month,d.day_of_month,(d.year)%100);
case 4:
return MSPrintF("%02d/%02d/%d",d.month,d.day_of_month,d.year);
case 5:
return MSPrintF("%3tZ %02d/%02d/%d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.month,d.day_of_month,d.year);
case 6:
return MSPrintF("%3tZ %02d",d.month-1,"ST_MONTHS",d.day_of_month);
case 7:
return MSPrintF("%3tZ, %3tZ %02d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.month-1,"ST_MONTHS",d.day_of_month);
case 8:
return MSPrintF("%3tZ %02d,%04d",d.month-1,"ST_MONTHS",d.day_of_month,d.year);
case 9:
return MSPrintF("%3tZ, %3tZ %02d,%d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.month-1,"ST_MONTHS",d.day_of_month,d.year);
case 10:
return MSPrintF("%Z %d",d.month-1,"ST_MONTHS",d.day_of_month);
case 11:
return MSPrintF("%Z, %Z %d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.month-1,"ST_MONTHS",d.day_of_month);
case 12:
return MSPrintF("%Z %d,%d",d.month-1,"ST_MONTHS",d.day_of_month,d.year);
case 13:
return MSPrintF("%Z, %Z %d,%d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.month-1,"ST_MONTHS",d.day_of_month,d.year);
case 14:
return MSPrintF("%02d/%02d/%02d",d.day_of_month,d.month,(d.year)%100);
case 15:
return MSPrintF("%02d/%02d",d.day_of_month,d.month);
case 16:
return MSPrintF("%3tZ %02d/%02d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.day_of_month,d.month);
case 17:
return MSPrintF("%3tZ %02d/%02d/%02d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.day_of_month,d.month,(d.year)%100);
case 18:
return MSPrintF("%02d/%02d/%d",d.day_of_month,d.month,d.year);
case 19:
return MSPrintF("%3tZ %02d/%02d/%d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.day_of_month,d.month,d.year);
case 20:
return MSPrintF("%02d %3tZ",d.day_of_month,d.month-1,"ST_MONTHS");
case 21:
return MSPrintF("%3tZ, %02d %3tZ",d.day_of_week,"ST_DAYS_OF_WEEK",
d.day_of_month,d.month-1,"ST_MONTHS");
case 22:
return MSPrintF("%02d %3tZ,%04d",d.day_of_month,d.month-1,"ST_MONTHS",d.year);
case 23:
return MSPrintF("%3tZ, %02d %3tZ,%d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.day_of_month,d.month-1,"ST_MONTHS",d.year);
case 24:
return MSPrintF("%d %Z",d.day_of_month,d.month-1,"ST_MONTHS");
case 25:
return MSPrintF("%Z, %d %Z",d.day_of_week,"ST_DAYS_OF_WEEK",
d.day_of_month,d.month-1,"ST_MONTHS");
case 26:
return MSPrintF("%d %Z,%d",d.day_of_month,d.month-1,"ST_MONTHS",d.year);
case 27:
return MSPrintF("%Z, %d %Z,%d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.day_of_month,d.month-1,"ST_MONTHS",d.year);
case 28:
return MSPrintF("%02d/%02d/%02d",(d.year)%100,d.month,d.day_of_month);
case 29:
return MSPrintF("%d/%02d/%02d",d.year,d.month,d.day_of_month);
case 30:
return MSPrintF("%02d%02d%02d",(d.year)%100,d.month,d.day_of_month);
case 31:
return MSPrintF("%d%02d%02d",d.year,d.month,d.day_of_month);
case 32:
return MSPrintF("%02d%02d%02d",d.month,d.day_of_month,(d.year)%100);
case 33:
return MSPrintF("%02d%02d%d",d.month,d.day_of_month,d.year);
case 34:
return MSPrintF("%3tZ",d.day_of_week,"ST_DAYS_OF_WEEK");
case 35:
return MSPrintF("%Z",d.day_of_week,"ST_DAYS_OF_WEEK");
case 36:
return MSPrintF("%3tZ",d.month-1,"ST_MONTHS");
case 37:
return MSPrintF("%Z",d.month-1,"ST_MONTHS");
case 38:
return MSPrintF("%d %3tZ",d.year,d.month-1,"ST_MONTHS");
case 39:
return MSPrintF("%d %Z",d.year,d.month-1,"ST_MONTHS");
case 40:
return MSPrintF("%02d %3tZ",(d.year)%100,d.month-1,"ST_MONTHS");
case 41:
return MSPrintF("%02d %Z",(d.year)%100,d.month-1,"ST_MONTHS");
case 42:
return MSPrintF("%3tZ %d",d.month-1,"ST_MONTHS",d.year);
case 43:
return MSPrintF("%Z %d",d.month-1,"ST_MONTHS",d.year);
case 44:
return MSPrintF("%3tZ %02d",d.month-1,"ST_MONTHS",(d.year)%100);
case 45:
return MSPrintF("%Z %02d",d.month-1,"ST_MONTHS",(d.year)%100);
case 46:
return MSPrintF("%02d",(d.year)%100);
case 47:
return MSPrintF("%d",d.year);
default:
return MSPrintF("%02d/%02d/%02d",d.month,d.day_of_month,(d.year)%100);
}
}
I1 *SPrintFJoin2(I1 *dst,I1 *src,I8i argc,I8i *argv)
{
I1 ch,*ptr,**addr_buf,*buf=NULL,*addr_dst,
*temp1;
BoolU4 pad_zero,left_justify,truncate,neg,neg_e;
I8 i;
I8 k,len,dec_len,sub_format;
U8 d,cur_param=0;
double dd,dd1,*dd_ptr;
I1 temp_buf[80];
argc; //ref so no warning
if (dst) {
addr_buf=NULL;
} else {
buf=MAlloc(256);
addr_buf=&buf;
dst=buf;
}
addr_dst=&dst;
while (ch = *(src++)) {
if (ch=='%') {
if (*src=='-') {
left_justify=TRUE;
src++;
} else
left_justify=FALSE;
if (*src=='0') {
pad_zero=TRUE;
src++;
} else
pad_zero=FALSE;
len=0;
while (*src>='0' && *src<='9')
len=len*10+ *(src++)-'0';
if (*src=='*') {
src++;
len=argv[cur_param++];
}
dec_len=0;
if (*src=='.') {
src++;
while (*src>='0' && *src<='9')
dec_len=dec_len*10+ *(src++)-'0';
if (*src=='*') {
src++;
dec_len=argv[cur_param++];
}
}
if (*src=='t') {
src++;
truncate=TRUE;
} else
truncate=FALSE;
sub_format=0;
if (*src=='h') {
src++;
while (*src>='0' && *src<='9')
sub_format=sub_format*10+ *(src++)-'0';
if (*src=='*') {
src++;
sub_format=argv[cur_param++];
}
}
neg=FALSE;
k=0;
switch (*src++) {
case 's':
ptr=argv[cur_param++];
OutString(ptr,addr_buf,addr_dst,len,left_justify,truncate);
break;
case 'S':
ptr=SysText(argv[cur_param++]);
OutString(ptr,addr_buf,addr_dst,len,left_justify,truncate);
break;
case 'F':
ptr=ReadTextFile(argv[cur_param++]);
if (ptr) {
OutString(ptr,addr_buf,addr_dst,len,left_justify,truncate);
Free(ptr);
}
break;
case 'Q':
ptr=argv[cur_param++];
while (ch=*ptr++) {
if (ch=='$$') {
OutChar(addr_dst,ch,addr_buf);
OutChar(addr_dst,ch,addr_buf);
} else if (ch==CH_LINE_FEED){
OutChar(addr_dst,'\\',addr_buf);
OutChar(addr_dst,'n',addr_buf);
} else if (ch==CH_CR){
OutChar(addr_dst,'\\',addr_buf);
OutChar(addr_dst,'r',addr_buf);
} else if (ch==CH_TAB){
OutChar(addr_dst,'\\',addr_buf);
OutChar(addr_dst,'t',addr_buf);
} else {
if (ch=='"' || ch=='\\')
OutChar(addr_dst,'\\',addr_buf);
OutChar(addr_dst,ch,addr_buf);
}
}
break;
case 'z':
ptr=PointAtListEntry(argv[cur_param],argv[cur_param+1]);
cur_param=cur_param+2;
OutString(ptr,addr_buf,addr_dst,len,left_justify,truncate);
break;
case 'Z':
ptr=SysTextSub(argv[cur_param],argv[cur_param+1]);
cur_param=cur_param+2;
OutString(ptr,addr_buf,addr_dst,len,left_justify,truncate);
break;
case 'c':
OutChar(addr_dst,argv[cur_param++],addr_buf);
break;
case 'D':
temp1=MSPrintFDate(argv[cur_param++],sub_format);
OutString(temp1,addr_buf,addr_dst,len,left_justify,truncate);
Free(temp1);
break;
case 'T':
temp1=MSPrintFTime(argv[cur_param++],sub_format);
OutString(temp1,addr_buf,addr_dst,len,left_justify,truncate);
Free(temp1);
break;
case 'P':
if (truncate)
temp1=MSPrintFPSect(argv[cur_param++],len);
else
temp1=MSPrintFPSect(argv[cur_param++],0);
OutString(temp1,addr_buf,addr_dst,len,left_justify,truncate);
Free(temp1);
break;
case 'd':
i=argv[cur_param++];
if (i<0) {
neg=TRUE;
i=-i;
}
while (!k || i) {
temp_buf[k++]=ModU8(i,10)+'0';
i=DivU8(i,10);
}
out_num:
i=(neg)? 1:0;
if (truncate && k+i>len)
k=len-i;
if (pad_zero)
for (;i<len-k;i++)
OutChar(addr_dst,'0',addr_buf);
else
for (;i<len-k;i++)
OutChar(addr_dst,32,addr_buf);
if (neg)
OutChar(addr_dst,'-',addr_buf);
for (i=k-1;i>=0;i--)
OutChar(addr_dst,temp_buf[i],addr_buf);
break;
case 'u':
d=argv[cur_param++];
while (!k|| d) {
temp_buf[k++]=ModU8(d,10)+'0';
d=DivU8(d,10);
}
goto out_num;
case 'f':
dd_ptr=&argv[cur_param++];
dd=*dd_ptr;
if (dd<0) {
neg=TRUE;
dd=-dd;
}
out_f:
if (i=dec_len)
dd*=Pow10(i);
dd=Round(dd);
while (i--) {
temp_buf[k++]=dd%10+'0';
dd=Floor(dd/10);
}
if (dec_len)
temp_buf[k++]='.';
do {
temp_buf[k++]=dd%10+'0';
dd=Floor(dd/10);
} while (dd);
goto out_num;
case 'e':
if (!len) len=12;
dd_ptr=&argv[cur_param++];
dd=*dd_ptr;
if (dd<0) {
neg=TRUE;
dd=-dd;
}
dd1=(dd) ? Log10(dd):0;
dd1=Round(dd1);
out_e:
dd/=Pow10(dd1);
if (dd1<0) {
dd1=-dd1;
neg_e=TRUE;
} else
neg_e=FALSE;
if (dd) {
if (dd<1.0) {
dd*=10;
if (neg_e)
dd1+=1;
else
dd1-=1;
} else if (dd>=10.0) {
dd/=10;
if (neg_e)
dd1-=1;
else
dd1+=1;
}
}
i=3;
do {
temp_buf[k++]=dd1%10+'0';
dd1=Floor(dd1/10);
} while (dd1 && i--);
if (neg_e)
temp_buf[k++]='-';
temp_buf[k++]='e';
dec_len=len-k-neg-2;
goto out_f;
case 'g':
if (!len) len=12;
dd_ptr=&argv[cur_param++];
dd=*dd_ptr;
if (dd<0) {
neg=TRUE;
dd=-dd;
}
dd1=(dd) ? Log10(dd):0;
dd1=Round(dd1);
if (dd1>=(len-1-dec_len) || dd1<-(dec_len-1))
goto out_e;
else
goto out_f;
case 'X':
d=argv[cur_param++];
while (!k || d) {
temp_buf[k]=(d & 15)+'0';
if (temp_buf[k]>'9') temp_buf[k]+='A'-0x3A;
k++;
d>>=4;
}
goto out_num;
case 'x':
d=argv[cur_param++];
while (!k || d) {
temp_buf[k]=(d & 15)+'0';
if (temp_buf[k]>'9') temp_buf[k]+='a'-0x3A;
k++;
d>>=4;
}
goto out_num;
case 'b':
d=argv[cur_param++];
while (!k || d) {
temp_buf[k++]=(d&1)+'0';
d>>=1;
}
goto out_num;
case '%':
OutChar(addr_dst,'%',addr_buf);
break;
}
} else
OutChar(addr_dst,ch,addr_buf);
}
OutChar(addr_dst,0,addr_buf);
return buf;
}
double A2Double(I1 *src,I1 **end_ptr=NULL)
{
I1 ch=*src++;
I8 i=0,j=0,k=0;
double d;
BoolU4 neg=FALSE;
while (ch==CH_SPACE||ch==CH_TAB||ch==CH_SHIFT_SPACE)
ch=*src++;
if (ch=='-') {
neg=TRUE;
ch=*src++;
}
while (TRUE) {
if (Bt(dec_numeric_bitmap,ch))
i=MulU8(i,10)+ch-'0';
else {
if (ch=='.' || ch=='e' || ch=='E') break;
d=i;
goto a2d_end;
}
ch=*src++;
}
if (ch=='.')
ch=*src++;
while (TRUE) {
if (Bt(dec_numeric_bitmap,ch)) {
j=MulU8(j,10)+ch-'0';
k++;
} else {
d=i+j*Pow10(-k);
if (ch=='e' || ch=='E') break;
goto a2d_end;
}
ch=*src++;
}
ch=*src++;
k=1;
if (ch=='-') {
k=-1;
ch=*src++;
}
j=0;
while (TRUE) {
if (Bt(dec_numeric_bitmap,ch))
j=MulU8(j,10)+ch-'0';
else {
d*=Pow10(j*k);
goto a2d_end;
}
ch=*src++;
}
a2d_end:
if (end_ptr) *end_ptr=src-1;
return (neg) ? -d:d;
}
/*
A2LTDate()
This routine recognizes the following formats:
1) "*+nnnn" "*-nnnnn"
2) mm/dd
3) mm/dd/yy
*/
LTDate A2LTDate(I1 *src2)
{
LTDate result=0;
LTDateStruct d,d1;
I1 *src=MStringUtil(src2,SU_REMOVE_SPACES|SU_TO_UPPER),
*v=NewString(src),
*p1=src;
BoolU4 start_month=FALSE,end_month=FALSE;
BoolU4 start_year=FALSE,end_year=FALSE;
MemSet(&d,0,sizeof(LTDateStruct));
MemSet(&d1,0,sizeof(LTDateStruct));
if (!StrNCmp(p1,"SM(",3)) {
p1+=3;
start_month=TRUE;
} else if (!StrNCmp(p1,"EM(",3)) {
p1+=3;
end_month=TRUE;
} else if (!StrNCmp(p1,"SY(",3)) {
p1+=3;
start_year=TRUE;
} else if (!StrNCmp(p1,"EY(",3)) {
p1+=3;
end_year=TRUE;
}
if (*p1=='*') {
p1++;
if (*p1=='+' || *p1=='-')
result.date=AtoI(p1,10,&p1);
result+=GetCurTimeLTDate;
} else {
RemoveFirstSeg(p1,"/",v); //Put month into v
d.month=AtoI(v);
if (Occurrences(p1,'/')) {
RemoveFirstSeg(p1,"/",v); //Put day into v leaving year in p1
d.day_of_month=AtoI(v);
d.year=AtoI(p1,10,&p1);
if (d.year<100) //if not 4 digit year
d.year+=2000;
} else {
d.day_of_month=AtoI(p1,10,&p1);
ToLTDateStruct(&d1,GetCurTimeLTDate);
d.year=d1.year;
}
result=ToLTDate(&d);
}
if (*p1==')') p1++;
if (start_month)
result.date=FirstDayOfMonth(result.date);
else if (end_month)
result.date=LastDayOfMonth(result.date);
else if (start_year)
result.date=FirstDayOfYear(result.date);
else if (end_year)
result.date=LastDayOfYear(result.date);
if (*p1=='+' || *p1=='-')
result.date+=AtoI(p1);
Free(src);
Free(v);
return result;
}
void GetFJoin2(I1 *src,I1 *fmt,I8i argc,I8i *argv)
//Pass pointer to data,
//For %s pass pointer to pointer (be careful because address
// of array is the same as array--create ptr to array and take address
{
I1 ch,*buf,*ptr,**pptr;
BoolU4 left_justify=FALSE;
I8 cur_param=0,i,j,k,len,*i_ptr,sub_format=0,dec_len;
double *d_ptr;
argc; //ref so no warning
while (ch = *(fmt++)) {
if (ch=='%') {
if (*fmt=='%') {
src++;
fmt++;
} else {
if (*fmt=='-') {
left_justify=TRUE;
fmt++;
} else
left_justify=FALSE;
len=0;
while (*fmt>='0' && *fmt<='9')
len=len*10+ (*(fmt++)-'0');
if (*fmt=='*') {
fmt++;
len=argv[cur_param++];
}
ch=*(fmt++);
if (ch && !len) {
ptr=src;
while (*ptr && *ptr!=*fmt)
ptr++;
len=ptr-src;
} else {
if (ch=='.') {
dec_len=0;
while (*fmt>='0' && *fmt<='9')
dec_len=dec_len*10+ (*(fmt++)-'0');
if (*fmt=='*') {
fmt++;
dec_len=argv[cur_param++];
}
ch=*(fmt++);
}
}
buf=MAlloc(len+1);
for (i=0;i<len;i++)
buf[i]=*(src++);
buf[i]=0;
switch (ch) {
case 's':
pptr=argv[cur_param++];
StrCpy(*pptr,buf);
break;
case 'c':
ptr=argv[cur_param++];
*ptr=*buf;
break;
case 'z':
i_ptr=argv[cur_param++];
*i_ptr=MatchListEntry(buf,argv[cur_param++]);
break;
case 'Z':
i_ptr=argv[cur_param++];
*i_ptr=MatchSysTextEntry(buf,argv[cur_param++]);
break;
case 'd':
i_ptr=argv[cur_param++];
*i_ptr=0;
for (k=0;k<len;k++)
if (buf[k]!=32)
*i_ptr=MulI8(*i_ptr,10)+(buf[k]-'0');
break;
case 'X':
i_ptr=argv[cur_param++];
*i_ptr=0;
for (k=0;k<len;k++)
if (buf[k]!=32) {
j=ToUpper(buf[k])-'0';
if (j>9) j=j-'A'+('9'+1);
*i_ptr=(*i_ptr<<4)+j;
}
break;
case 'b':
i_ptr=argv[cur_param++];
*i_ptr=0;
for (k=0;k<len;k++)
if (buf[k]!=32)
*i_ptr=*i_ptr<<1+(buf[k]-'0');
break;
case 'e':
case 'f':
case 'g':
d_ptr=argv[cur_param++];
*d_ptr=A2Double(buf);
break;
case 'D':
i_ptr=argv[cur_param++];
*i_ptr=A2LTDate(buf)>>32;
break;
}
Free(buf);
}
} else
src++;
}
}
+34
View File
@@ -0,0 +1,34 @@
exe {KeepPrivate(ON);}
exe {Externs2Imports(ON);}
#include "/LT/OSMain/ADAMK.HPZ"
#include "/LT/OSMain/ADAMK2.HPZ"
#include "/LT/OSMain/ADAMK3.HPZ"
exe {KeepPrivate(OFF);}
exe {Externs2Imports(OFF);}
exe {PTrace(ON);}
exe {OTrace(ON);}
exe {CTrace(ON);}
void Test()
{
I8 i;
for (i=0;i<8;i++) {
coutln 1,2,3,4,i;
}
}
void Test1()
{
I8 i;
for (i=0;i<8;i++) {
coutln 1,2,3,4,i;
}
}
void Test2()
{
I8 i;
for (i=0;i<8;i++) {
coutln 1,2,3,4,i;
}
}
Binary file not shown.