diff --git a/cc_core.c b/cc_core.c index f11f023..17195d2 100644 --- a/cc_core.c +++ b/cc_core.c @@ -49,8 +49,6 @@ void require(int bool, char* error); struct token_list* reverse_list(struct token_list* head); struct type* mirror_type(struct type* source, char* name); struct type* add_primitive(struct type* a); -/* Host touchy function will need custom on 64bit systems*/ -int fixup_int32(int a); struct token_list* emit(char *s, struct token_list* head) { @@ -503,7 +501,7 @@ void primary_expr_number() { if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) { - int size = fixup_int32(numerate_string(global_token->s)); + int size = numerate_string(global_token->s); if((32767 > size) && (size > -32768)) { emit_out("LOADI R0 "); diff --git a/functions/fixup.c b/functions/fixup.c deleted file mode 100644 index 45b438b..0000000 --- a/functions/fixup.c +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (C) 2016 Jeremiah Orians - * This file is part of M2-Planet. - * - * M2-Planet is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * M2-Planet is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with M2-Planet. If not, see . - */ - -/* This only works for 32bit architectures */ -int fixup_int32(int a) -{ - return a; -} diff --git a/functions/numerate_number.c b/functions/numerate_number.c index f468c04..fc7d5e8 100644 --- a/functions/numerate_number.c +++ b/functions/numerate_number.c @@ -150,29 +150,34 @@ int set_reader(char* set, int mult, char* input) int numerate_string(char *a) { + int result = 0; /* If NULL string */ if(0 == a[0]) { - return 0; + result = 0; } /* Deal with binary*/ else if ('0' == a[0] && 'b' == a[1]) { - return set_reader("01", 2, a+2); + result = set_reader("01", 2, a+2); } /* Deal with hex */ else if ('0' == a[0] && 'x' == a[1]) { - return set_reader("0123456789ABCDEFabcdef", 16, a+2); + result = set_reader("0123456789ABCDEFabcdef", 16, a+2); } /* Deal with octal */ else if('0' == a[0]) { - return set_reader("01234567", 8, a+1); + result = set_reader("01234567", 8, a+1); } /* Deal with decimal */ else { - return set_reader("0123456789", 10, a); + result = set_reader("0123456789", 10, a); } + + /* Deal with sign extension */ + if(0 != (0x80000000 & result)) result = (0xFFFFFFFF << 31) | result; + return result; } diff --git a/makefile b/makefile index 46089db..0710a2e 100644 --- a/makefile +++ b/makefile @@ -34,7 +34,6 @@ M2-Planet: bin results cc.h cc_reader.c cc_strings.c cc_types.c cc_core.c cc.c c functions/number_pack.c \ functions/string.c \ functions/require.c \ - functions/fixup.c \ cc_reader.c \ cc_strings.c \ cc_types.c \ @@ -55,7 +54,6 @@ M2-minimal: bin results cc.h cc_reader.c cc_strings.c cc_types.c cc_core.c cc-mi functions/number_pack.c \ functions/string.c \ functions/require.c \ - functions/fixup.c \ cc_reader.c \ cc_strings.c \ cc_types.c \ diff --git a/test/common_aarch64/functions/fixup.c b/test/common_aarch64/functions/fixup.c deleted file mode 100644 index f77a472..0000000 --- a/test/common_aarch64/functions/fixup.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2016 Jeremiah Orians - * This file is part of M2-Planet. - * - * M2-Planet is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * M2-Planet is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with M2-Planet. If not, see . - */ - - -int fixup_int32(int a) -{ - if(0 != (0x80000000 & a)) - { - a = a << 32; - a = a >> 32; - } - - return a; -} diff --git a/test/common_amd64/functions/fixup.c b/test/common_amd64/functions/fixup.c deleted file mode 100644 index f62d8eb..0000000 --- a/test/common_amd64/functions/fixup.c +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (C) 2016 Jeremiah Orians - * This file is part of M2-Planet. - * - * M2-Planet is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * M2-Planet is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with M2-Planet. If not, see . - */ - -/* Only works for AMD64 with the value in RAX */ -int fixup_int32(int a) -{ - asm("LOAD_EFFECTIVE_ADDRESS_rax %8" - "LOAD_INTEGER" - "MOVESX"); -} diff --git a/test/test.answers b/test/test.answers index c663244..8f76757 100644 --- a/test/test.answers +++ b/test/test.answers @@ -109,11 +109,11 @@ c8917a882cf4eaf6c332ef35793aaf4a6a58ac075cb041ebc7e1290c3129cb58 test/results/t f31fbd190e6dceda05b33a71692926845127f4f73eab08a143a17b5f2611e6e3 test/results/test0018-knight-native-binary 4f794e6dae2c21dc9ebe611a4be616d5c67f30b110ad7b7b81c0a19717c39932 test/results/test0018-knight-posix-binary 1ccbc54c2a2a722107b7ba9d282d65c2d975541a33d615a5ddcf468281a29153 test/results/test0018-x86-binary -1daea3056216afc8500c1de92df40dc8c6d5e3b0a15aa85015a9673a6b91b70c test/results/test0019-aarch64-binary -7c0fcc833a7c3a5b5d36cf389e9c72873a25843e10cb3cbb4f42b3cf875104aa test/results/test0019-amd64-binary -59eac9790e0026021612d485495ba558dd5d5122019b9b43259318c94856d3c5 test/results/test0019-armv7l-binary -9f7340c233db8d21ed37aa9c9b9998e7e9e3770df5c86a75411737af28f568d4 test/results/test0019-knight-posix-binary -87b38ccee5606d23c5f6286defb0c83d9271cd361af879e9f5c38471b9f77ab7 test/results/test0019-x86-binary +ad5266a63744471b352830bff2d65adcb77918feee3e90b8434f13865fb3a8c1 test/results/test0019-aarch64-binary +2004d08638db6c40d263a514d47c24ca3702dc9786e7a867b087b0b5f6437e77 test/results/test0019-amd64-binary +a2c49d4e861e11c1dd757b274b46296fce3761e5b66534a2eedc27cca56b0a3f test/results/test0019-armv7l-binary +438924d86787f2d613ebcf1a33e88d3d4ab45d529d0c0b3bb3dc0c7f7675fc20 test/results/test0019-knight-posix-binary +adf4cd12871da97065261fda59fe62f024a0d831d4a3bc7a80c7c3b2ed54e172 test/results/test0019-x86-binary 52d849336725092ab929ab372326b795b5810d159adc81c5a667bc0ed6c9d353 test/results/test0020-aarch64-binary 5bf34266efdd7423733bc99a01c7e248110950e28dcc0cc768c189f286d6402a test/results/test0020-amd64-binary 1b0a548114f4e2d627049c5b64792701c8068bfdd33862af028374ab9f9cb3a1 test/results/test0020-armv7l-binary @@ -125,11 +125,11 @@ de8c8105ec9eb9f3ca398e7efaba61a86c5022363ebe0a010502e667de0260c1 test/results/t 6d578501c5a8bdc342f2860576b0c66a129cbd4a20f1560bc3ce8f221db24999 test/results/test0021-armv7l-binary 7a2be9cc1306aed5be7a0f1652f3094754c959e39271e03513550ed1bebd66d0 test/results/test0021-knight-posix-binary 03678678921abdee02400158fda39c11ec927b1077953b19be0df553fa7fe4cd test/results/test0021-x86-binary -ee7d18937cbd4033a638bec2334a84b43f2720f3bc214f580a92d445899bb7a5 test/results/test0022-aarch64-binary -d4f57528efe1a879ea97aae42a2de4575beb44d074ee178b00af72ffd727c59e test/results/test0022-amd64-binary -34e4c59d0ec56bb9f9a944953fa5d99fd200d73c725f6dde45bac9e133476515 test/results/test0022-armv7l-binary -9f09a88bec987bcfcce4a94c567202e1c7317e85f98f517ecb3e6e9b1830e9d5 test/results/test0022-knight-posix-binary -c648e06c65d7dfb35f1dfd1b8749587905ded1c048c4d9a7953fe9fe271386a5 test/results/test0022-x86-binary +cc4d9c0fde057f6b2aa5170d8cd713ef811e7d01b18a281a560ea28dfce090b8 test/results/test0022-aarch64-binary +f7f6efb36a7f68189c050b8f623a760c0113ad676a37a39dd745ad4c9ab79e67 test/results/test0022-amd64-binary +9a7fef74e3541489450eea8ebe713215eb75e0ccf8990e0b8cac85993d22a28d test/results/test0022-armv7l-binary +14d4287989a3468743321ed004ccb7c5018226e1e23b7eb32eb7246b95564539 test/results/test0022-knight-posix-binary +4f2d9665b7f1b781b6159a5631e6f29ce0bff7e143bc5add941ff350f231c7be test/results/test0022-x86-binary 7e88cd71f4751e164fb4a5c2c12cf2b1feb10ff8ed3fbd3537fdc1b19022ad5e test/results/test0023-aarch64-binary 2dfd739fda224674da364784c68ab4f261d28056c746c0588b1b65e37371c05a test/results/test0023-amd64-binary 3d135524be40b706a1379ac3b2f10fe342355d111b6c8e18c157dbff72a86611 test/results/test0023-armv7l-binary @@ -150,37 +150,37 @@ d27e36cc2f30f69bd8bb86cef41241fbe35bcace6a179f952dbb51853b995a35 test/results/t 174c5d09252e8056e1fbc11bb5bd637a5eeee26b7cf2867fa031c165209f4245 test/results/test0100-armv7l-binary ebecf1e841c9c6ef03eb656d8aa17722624728285df26db136c89a583f67f7b8 test/results/test0100-knight-posix-binary 04fecc4f2ee31911f5900a2760cd568665a40f426e889f819beaf2b81c9967fb test/results/test0100-x86-binary -8c787dabe68043e0b96ff6d055ccfd30b68624d5d897571465ed6aca2d1931b7 test/results/test0101-aarch64-binary -d2e805a7016845017d9d5e8f26c1e5e3c4b7570bfa434badd9abe62f8f14233f test/results/test0101-amd64-binary -63d96d4455dd2ae922a559e9ac202349c4ecdae908542256e96a3622c8eb7447 test/results/test0101-armv7l-binary -195330cf34ca3e89506724fa4673b05d1895e5d33c845ef2ef8bb3620c9ade83 test/results/test0101-knight-posix-binary -ea87d209b9f2c11c18916da2591f1509b857ba68776d7a3ff86b3d7b1302db63 test/results/test0101-x86-binary -3dcca356b5059d55a7032f98fdbed7fcc0cbecca0b5aeae35e68806b89c6f3a0 test/results/test0102-aarch64-binary -c995bf881a3745164cc28ed5b2ad239f954afa64bc85455561c9ab197f2291d1 test/results/test0102-amd64-binary -1fd54fe07a9269be3b7cca64df32284dd01efb160bab6d5aa982f8f52c88e95f test/results/test0102-armv7l-binary -f4e721cb873ef5f2d1140bf2fc2dc83f58b641b8e7efe3e8314816401aa00662 test/results/test0102-knight-posix-binary -5f1e19bdb86c4320be6553a5160af6babbe25688c30a6e67db05d8bb645247b8 test/results/test0102-x86-binary +3e3ab5c8f005065e0fa241c5fef24c0f4dd55653fb7934f447a489f4705da26d test/results/test0101-aarch64-binary +e877e912e4d0c97de7b8fa29bde8e4a11c1268f76fc77605a1da828eef41765c test/results/test0101-amd64-binary +932afbd738b8cd3231f225abcacf1b4f805c3cddba598ed9d2866aa30fbbeddf test/results/test0101-armv7l-binary +7f1b32f58dc1c4dfb9e61a809033399e305b28e3e45611e1dc2a9a45f33f1e02 test/results/test0101-knight-posix-binary +9f68d3a61d739cbbe516fbeff7c8718273ffd006dbad5baaf23e1b9d99234898 test/results/test0101-x86-binary +80abae15c43afdd4bc9f246adba4a9456f525f97d9e67809c0e2135d26084bac test/results/test0102-aarch64-binary +ee00bf698b4208b4a9af49b2d66cb5f46d48177568a63e73623b22f2234fc501 test/results/test0102-amd64-binary +ad15c80b01bbcb22c746a7cc9e8c288b31dc793e23ea1d1a002f6d3505a0cae8 test/results/test0102-armv7l-binary +c8f488b0d9121a490b3896424ebfff4293cddd6b5073eb3b041fe18c648d6636 test/results/test0102-knight-posix-binary +eb2d27296553bd11d358d3ac08ba11b364d4cc3d5b30f3aa53ead58f514d4d48 test/results/test0102-x86-binary 42dd36b4f4975fdb432eb84bc908fbc818a19bc8b703c471bae68ed87b101a81 test/results/test0103-aarch64-binary cdcee7eb9b08f3d0eba59b68f4adafc714293c6387782f70f68c6d7349fb31fd test/results/test0103-amd64-binary e286f97af6d1e54824416e4a1b842d6d9ca73ef805b0b5129bfeabce01642b55 test/results/test0103-armv7l-binary dcafe5bc21227014b0377a445fcc9e7025babed62bfeb6eb6455d006392b07a6 test/results/test0103-knight-posix-binary 897c47ec05e1f1b75ca433578b47692b27884cad7297eae901cf347d768717de test/results/test0103-x86-binary -9d25845442c0f97f5f597d9db210da7430ca291c2cb8730d8bb592080bb6c0a3 test/results/test0104-aarch64-binary -001331e713b094e78cf4fe91811e7d573bdfbe96ce6faa27fc70c0cb04a710ea test/results/test0104-amd64-binary -563f4bd3a387a29e3ce867c7569dcb7daa8a9967267b538d34041e5d80fbb48f test/results/test0104-armv7l-binary -d76e571526ae35c59bb2d022ed52ae5ff7d79a6790939c3251458d4cad0a4f75 test/results/test0104-x86-binary -4e9837ca7469f16ed6d84ffe8e8b27c60d16126aa664ab4fd7c7530d18c027a6 test/results/test0105-aarch64-binary -54621f85782514a4fb8c16d8cf2796f6b88484ab0d06c379bf1d916d67fbd5bb test/results/test0105-amd64-binary -d14529ef7c2c2af6a911027a33f05c14b1f772e8df29f28ed103c69c653ee442 test/results/test0105-armv7l-binary -46a5e68ffa6c12cbbfa6229926a0af08d3331bef41d233f3ac4a0335fe385c27 test/results/test0105-x86-binary +3d47ece1712be1cac9b11e4af4a98749cb11ce4f4f76817dbfbad649a64c9759 test/results/test0104-aarch64-binary +211be7bf8510f260822904bb7c4050f10630f256ec54d1e69f532d5b11238acf test/results/test0104-amd64-binary +d8595a6f0a41e71edfbb364bfbae796dfbfd38200847e645e89ccddc5922e4c9 test/results/test0104-armv7l-binary +e470a5c39a269a4a4a5aef790e3fabd355b265f8de3a4a05553a899d76db44c5 test/results/test0104-x86-binary +814987a182c1dbaf5db45de7f2249c3b9a189afc326e281f223cc537695feb45 test/results/test0105-aarch64-binary +8ffe02e6010005b297a5cfabdbcfe30ac2b3c3e7371b483347c4c258c851e289 test/results/test0105-amd64-binary +93c0c4db00f9ffd351bb3ec72a4d9db582154f7f12c2ecd4c26508854ec6c9f9 test/results/test0105-armv7l-binary +b69ea75698be9265c2c9bd6be748a893dc289acd10f64999230fc392010d9a87 test/results/test0105-x86-binary ca9fdf7c6720b7aff8a37a60608b89bb4a6941aa323c7038e0bcbb01af9a568d test/results/test0106-aarch64-binary 447d78cd2526ef97cdf02f72bc2f492765f7c076c598cf3dbd3e8dd4507740b7 test/results/test0106-amd64-binary ba2e2e1bbe66fea15d5984678175229fcb0adc6faa394be2cfde8bea1d3026de test/results/test0106-armv7l-binary 698853b79efb30865a663c4863c050639eb21c7400008f7840830503928973d4 test/results/test0106-knight-native-binary 44d0b9e0433f12b5567ecddc9285b6a7d41ea646a7134e6fc3c394b4a973f6ba test/results/test0106-knight-posix-binary 1f83e1cbac44aabd9f87eae601e020b584b572e7edb738d6274972d6d100fa3c test/results/test0106-x86-binary -50366dc84533f1a5f087abfe41995f5c308163ab905595f307b4a01273a27348 test/results/test1000-aarch64-binary -72f71f9ae18ba3f867ce3a2644a400ae6f2cb2138112c252b321094dc253eac3 test/results/test1000-amd64-binary -83a83816fc76d41d6b731d61461d73ff3390860a45218eb3236f7fa3bdf59eb0 test/results/test1000-armv7l-binary -4a3f310fda59dbf364ae80f633b24dd9c2931c573b9a40219a201a9d4f0a02b4 test/results/test1000-knight-posix-binary -ef370c3e31728e5494ac7fcc41c2f9b3f8c83e84b2e60da8a481521ecb4530cb test/results/test1000-x86-binary +f2fdafa1f4697d505f4e6b0305149e4a41fb50bae7024b420559ef8b42c5813a test/results/test1000-aarch64-binary +0ca1cd3601969f50596d8c46f43ba1ec8faf6de41deae69d8fb199b35a3a3c99 test/results/test1000-amd64-binary +869ff8d396e1d99897669733cf5756ef88c061689066163a969eb724e901a3e2 test/results/test1000-armv7l-binary +3758195a742867a22237a1371a5f4b19c4e9b8a0c6675d76f09fd748a46aed46 test/results/test1000-knight-posix-binary +72b941a1c9708605eb531702bbf2ddc2a21fc1a7f60977fa936dc6fbca3bea19 test/results/test1000-x86-binary diff --git a/test/test1000/hello-aarch64.sh b/test/test1000/hello-aarch64.sh index 9166ab9..4dcb1f6 100755 --- a/test/test1000/hello-aarch64.sh +++ b/test/test1000/hello-aarch64.sh @@ -35,7 +35,6 @@ mkdir -p ${TMPDIR} -f functions/number_pack.c \ -f functions/string.c \ -f functions/require.c \ - -f test/common_aarch64/functions/fixup.c \ -f cc.h \ -f cc_globals.c \ -f cc_reader.c \ diff --git a/test/test1000/hello-amd64.sh b/test/test1000/hello-amd64.sh index 5ad4845..49600c7 100755 --- a/test/test1000/hello-amd64.sh +++ b/test/test1000/hello-amd64.sh @@ -35,7 +35,6 @@ mkdir -p ${TMPDIR} -f functions/number_pack.c \ -f functions/string.c \ -f functions/require.c \ - -f test/common_amd64/functions/fixup.c \ -f cc.h \ -f cc_globals.c \ -f cc_reader.c \ diff --git a/test/test1000/hello-armv7l.sh b/test/test1000/hello-armv7l.sh index eaee81a..470b84c 100755 --- a/test/test1000/hello-armv7l.sh +++ b/test/test1000/hello-armv7l.sh @@ -35,7 +35,6 @@ mkdir -p ${TMPDIR} -f functions/number_pack.c \ -f functions/string.c \ -f functions/require.c \ - -f functions/fixup.c \ -f cc.h \ -f cc_globals.c \ -f cc_reader.c \ diff --git a/test/test1000/hello-knight-posix.sh b/test/test1000/hello-knight-posix.sh index 5cd0838..feed2ac 100755 --- a/test/test1000/hello-knight-posix.sh +++ b/test/test1000/hello-knight-posix.sh @@ -35,7 +35,6 @@ mkdir -p ${TMPDIR} -f functions/number_pack.c \ -f functions/string.c \ -f functions/require.c \ - -f functions/fixup.c \ -f cc.h \ -f cc_globals.c \ -f cc_reader.c \ diff --git a/test/test1000/hello-x86.sh b/test/test1000/hello-x86.sh index 7a8f474..cb07074 100755 --- a/test/test1000/hello-x86.sh +++ b/test/test1000/hello-x86.sh @@ -35,7 +35,6 @@ mkdir -p ${TMPDIR} -f functions/number_pack.c \ -f functions/string.c \ -f functions/require.c \ - -f functions/fixup.c \ -f cc.h \ -f cc_globals.c \ -f cc_reader.c \ diff --git a/test/test1000/proof.answer b/test/test1000/proof.answer index 1deb2dd..9225ce9 100644 --- a/test/test1000/proof.answer +++ b/test/test1000/proof.answer @@ -1 +1 @@ -c7b2fa47fb9d938c5ec08b3d6182495bba14d31e7001345711bb257cd54e2b54 test/test1000/proof +c2edf691fa75b56e42a15b5dc62124a2a2f006cd38ad2f34d48be2563bd78620 test/test1000/proof