Subversion Repositories Kolibri OS

Rev

Rev 7406 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7406 Rev 7411
Line 1... Line 1...
1
// version 0.02
1
// version 0.03
2
// Author: Pavel Iakovlev
2
// Author: Pavel Iakovlev
3
// http://shell-storm.org/online/Online-Assembler-and-Disassembler/?inst=&arch=arm#assembly - online compiler (Little endian:)
3
// http://shell-storm.org/online/Online-Assembler-and-Disassembler/?inst=&arch=arm#assembly - online compiler (Little endian:)
Line 4... Line 4...
4
 
4
 
Line 25... Line 25...
25
char param[4096] ={0};
25
char param[4096] ={0};
26
char program_path[4096] = {0};
26
char program_path[4096] = {0};
Line 27... Line 27...
27
 
27
 
Line 28... Line 28...
28
// test opcode arm, compiler (http://shell-storm.org/online/Online-Assembler-and-Disassembler/?inst=mov+r0%2C1%0D%0Amov+r5%2C2%0D%0Amov+r2%2C+r0%2C+lsl+r5&arch=arm#assembly) (Little endian:)
28
// test opcode arm, compiler (http://shell-storm.org/online/Online-Assembler-and-Disassembler/?inst=mov+r0%2C1%0D%0Amov+r5%2C2%0D%0Amov+r2%2C+r0%2C+lsl+r5&arch=arm#assembly) (Little endian:)
Line 29... Line 29...
29
 
29
 
Line 30... Line 30...
30
dword test_bytecode = "\x01\x00\xa0\xe3\x02\x50\xa0\xe3\x10\x25\xa0\xe1"; 
30
dword test_bytecode = "\x04\x10\x5f\xe5\x7b\x00\x00\x00"; 
31
 
31
 
Line 83... Line 83...
83
_mask mask = {0,0}; // processor mask
83
_mask mask = {0,0}; // processor mask
Line 84... Line 84...
84
 
84
 
85
void main()
85
void main()
Line 86... Line 86...
86
{
86
{
Line 87... Line 87...
87
 
87
 
88
	callOpcode(#test_bytecode,3);
88
	callOpcode(#test_bytecode,1);
89
	
89
	
Line 130... Line 130...
130
		
130
		
131
		command = DSDWORD[binary + PC]; // generation PC instruction
131
		command = DSDWORD[binary + PC]; // generation PC instruction
132
		//EAX = DSDWORD[command >> 28 << 2 + #opcodeExec]; // get opcodeExecition call instruction
132
		//EAX = DSDWORD[command >> 28 << 2 + #opcodeExec]; // get opcodeExecition call instruction
133
		//EAX(command); // call opcodeExecition
133
		//EAX(command); // call opcodeExecition
134
		//IF (command & 0xC000000 == 0) opcodeExec0(command);
134
		//IF (command & 0xC000000 == 0) opcodeExec0(command);
135
		IF (command & 0x0FFFFFF0 == 0x12FFF10) BranchExchange(command);
135
		if (command & 0x0FFFFFF0 == 0x12FFF10) BranchExchange(command);
136
		ELSE IF (command & 0x0FF00FF0 == 0x1000090) SingleDataSwap(command);
136
		else if (command & 0x0FF00FF0 == 0x1000090) SingleDataSwap(command);
137
		ELSE IF (command & 0x0FC000F0 == 0x0000090) Multiply(command);
137
		else if (command & 0x0FC000F0 == 0x0000090) Multiply(command);
138
		ELSE IF (command & 0x0FC000F0 == 0x0800090) MultiplyLong(command);
138
		else if (command & 0x0FC000F0 == 0x0800090) MultiplyLong(command);
-
 
139
		else if (command & 0x0C000000 == 0x0000000) DataProcessing(command);
-
 
140
		else if (command & 0xE000010 == 0x6000010) ;// undefined
Line 139... Line 141...
139
		ELSE IF (command & 0x0C000000 == 0x0000000) DataProcessing(command);
141
		else if (command & 0xC000000 == 0x4000000) SingleDataTransfer(command, binary);
140
		
142
		
Line 141... Line 143...
141
		PC += 4; // addition 4 for reg15 or PC instruction
143
		PC += 4; // addition 4 for reg15 or PC instruction
Line 149... Line 151...
149
		
151
		
150
		pMask = 0;
152
		pMask = 0;
151
		IF (mask.IRQ)  pMask |= 0x2;
153
		IF (mask.IRQ)  pMask |= 0x2;
Line 152... Line 154...
152
		IF (mask.FIRQ) pMask |= 0x1;
154
		IF (mask.FIRQ) pMask |= 0x1;
153
		
155
		
154
		IF (mode.User)               pMode = 0;
156
		if (mode.User)               pMode = 0;
155
		ELSE IF (mode.FastInterrupt) pMode = 1;
157
		else IF (mode.FastInterrupt) pMode = 1;
Line 156... Line 158...
156
		ELSE IF (mode.Interrupt)     pMode = 2;
158
		else IF (mode.Interrupt)     pMode = 2;
157
		ELSE IF (mode.Supervisor)    pMode = 3;
159
		else IF (mode.Supervisor)    pMode = 3;
158
		
160
		
159
		//reg.r15 = flag << 28 | PC | pMode;
161
		//reg.r15 = flag << 28 | PC | pMode;
Line 179... Line 181...
179
dword BranchExchange(dword command)
181
dword BranchExchange(dword command)
180
{
182
{
Line 181... Line 183...
181
	
183
	
Line -... Line 184...
-
 
184
}
-
 
185
 
-
 
186
dword SingleDataTransfer(dword command, binary) 
-
 
187
{
-
 
188
	dword Rd = #reg;
-
 
189
	dword Rn = #reg;
-
 
190
	dword offset = 0;
-
 
191
 
-
 
192
	Rd += command >> 12 & 0xF << 2;
-
 
193
	Rn += command >> 16 & 0xF << 2;
-
 
194
	offset = command & 0xFFF;
-
 
195
	IF (command >> 16 & 0xF != 15) IF (command & 0x800000 == 0) $neg offset;
-
 
196
	
-
 
197
	IF (command & 0x400000) // byte
-
 
198
	{
-
 
199
		IF (command >> 16 & 0xF == 15) 
-
 
200
		{
-
 
201
			IF (command & 0x100000) DSDWORD[Rd] = DSBYTE[binary + offset];
-
 
202
			ELSE DSBYTE[binary + offset] = DSDWORD[Rd];
-
 
203
			
-
 
204
		}
-
 
205
		ELSE 
-
 
206
		{
-
 
207
			Rn = DSDWORD[Rn];
-
 
208
			IF (command & 0x2000000 == 0) Rn += offset;
-
 
209
			IF (command & 0x100000) DSDWORD[Rd] = DSDWORD[binary + Rn];
-
 
210
			ELSE DSDWORD[binary + Rn] = DSDWORD[Rd];
-
 
211
		}
-
 
212
	}
-
 
213
	ELSE // dword
-
 
214
	{
-
 
215
		Rn = DSDWORD[Rn];
-
 
216
		IF (command & 0x2000000 == 0) Rn += offset;
-
 
217
		IF (command & 0x100000) DSDWORD[Rd] = DSDWORD[binary + Rn];
-
 
218
		ELSE DSDWORD[binary + Rn] = DSDWORD[Rd];
-
 
219
	}
-
 
220
 
182
}
221
}
183
 
222
 
184
dword DataProcessing(dword command) // Data Processing / PSR Transfer
223
dword DataProcessing(dword command) // Data Processing / PSR Transfer
185
{
224
{
186
	dword opcode = 0;
225
	dword opcode = 0;
Line 204... Line 243...
204
 
243
 
205
	switch (typeSdvig) // type sdvig
244
	switch (typeSdvig) // type sdvig
206
	{
245
	{
207
		case 0: // logic left
246
		case 0: // logic left
208
			operand <<= sdvig;
-
 
209
			if(sdvig == 2) while(1);
247
			operand <<= sdvig;
210
		break;
248
		break;
211
		case 1: // logic right
249
		case 1: // logic right
212
			operand >>= sdvig;
250
			operand >>= sdvig;
213
		break;
251
		break;
Line 269... Line 307...
269
		break;
307
		break;
270
		case 15: // mvn 
308
		case 15: // mvn 
271
			DSDWORD[Rd] = DSDWORD[Rn] + operand;
309
			DSDWORD[Rd] = DSDWORD[Rn] + operand;
272
		break;
310
		break;
273
	}
311
	}
274
	IF(reg.r2 == 4) while(1);
-
 
-
 
312
	
275
}
313
}
Line 276... Line 314...
276
 
314
 
277
 
315