• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

Revisão243fb9ff0fb9fad9d242d9c10cfecb31aa0210f8 (tree)
Hora2009-05-15 11:42:17
AutorAndroid (Google) Code Review <android-gerrit@goog...>
CommiterAndroid (Google) Code Review

Mensagem de Log

Merge change 1740

* changes:

Implement <, >, ==, !=, >= <=, &&, and ||.

Mudança Sumário

Diff

--- a/libacc/acc.cpp
+++ b/libacc/acc.cpp
@@ -269,7 +269,7 @@ class compiler {
269269 fprintf(stderr, "functionExit(%d, %d, %d);\n", argCount, localVariableAddress, localVariableSize);
270270 // Patch local variable allocation code:
271271 if (localVariableSize < 0 || localVariableSize > 255) {
272- error("LocalVariableSize");
272+ error("localVariables out of range: %d", localVariableSize);
273273 }
274274 *(char*) (localVariableAddress) = localVariableSize;
275275
@@ -282,7 +282,7 @@ class compiler {
282282 // sp -> arg0 ....
283283 if (argCount > 0) {
284284 // We store the PC into the lr so we can adjust the sp before
285- // returning. (We need to pull off the registers we pushed
285+ // returning. We need to pull off the registers we pushed
286286 // earlier. We don't need to actually store them anywhere,
287287 // just adjust the stack.
288288 int regArgCount = argCount <= 4 ? argCount : 4;
@@ -309,28 +309,49 @@ class compiler {
309309
310310 virtual int gjmp(int t) {
311311 fprintf(stderr, "gjmp(%d);\n", t);
312- return o4(0xEA000000 + encodeAddress(t)); // b .L33
312+ return o4(0xEA000000 | encodeAddress(t)); // b .L33
313313 }
314314
315315 /* l = 0: je, l == 1: jne */
316316 virtual int gtst(bool l, int t) {
317317 fprintf(stderr, "gtst(%d, %d);\n", l, t);
318- error("Unimplemented");
319- o(0x0fc085); /* test %eax, %eax, je/jne xxx */
320- return psym(0x84 + l, t);
318+ o4(0xE3500000); // cmp r0,#0
319+ int branch = l ? 0x1A000000 : 0x0A000000; // bne : beq
320+ return o4(branch | encodeAddress(t));
321321 }
322322
323323 virtual void gcmp(int op) {
324324 fprintf(stderr, "gcmp(%d);\n", op);
325- error("Unimplemented");
326-#if 0
327- int t = decodeOp(op);
328- o(0xc139); /* cmp %eax,%ecx */
329- li(0);
330- o(0x0f); /* setxx %al */
331- o(t + 0x90);
332- o(0xc0);
333-#endif
325+ o4(0xE1510000); // cmp r1, r1
326+ switch(op) {
327+ case OP_EQUALS:
328+ o4(0x03A00001); // moveq r0,#1
329+ o4(0x13A00000); // movne r0,#0
330+ break;
331+ case OP_NOT_EQUALS:
332+ o4(0x03A00000); // moveq r0,#0
333+ o4(0x13A00001); // movne r0,#1
334+ break;
335+ case OP_LESS_EQUAL:
336+ o4(0xD3A00001); // movle r0,#1
337+ o4(0xC3A00000); // movgt r0,#0
338+ break;
339+ case OP_GREATER:
340+ o4(0xD3A00000); // movle r0,#0
341+ o4(0xC3A00001); // movgt r0,#1
342+ break;
343+ case OP_GREATER_EQUAL:
344+ o4(0xA3A00001); // movge r0,#1
345+ o4(0xB3A00000); // movlt r0,#0
346+ break;
347+ case OP_LESS:
348+ o4(0xA3A00000); // movge r0,#0
349+ o4(0xB3A00001); // movlt r0,#1
350+ break;
351+ default:
352+ error("Unknown comparison op %d", op);
353+ break;
354+ }
334355 }
335356
336357 virtual void genOp(int op) {