mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 06:48:31 +00:00
Add atomics to chibicc
This change also fixes #434 and makes the chibicc assembler better.
This commit is contained in:
parent
5ddf43332e
commit
a988896048
21 changed files with 650 additions and 445 deletions
21
third_party/chibicc/test/asm_test.c
vendored
21
third_party/chibicc/test/asm_test.c
vendored
|
@ -83,6 +83,24 @@ void testFlagOutputs(void) {
|
|||
ASSERT(false, sf);
|
||||
}
|
||||
|
||||
void testAugmentLoByte_onlyModifiesLowerBits(void) {
|
||||
int x, y;
|
||||
x = 0x01020304;
|
||||
y = 0x00000005;
|
||||
asm("sub\t%b1,%b0" : "+q"(x) : "q"(y));
|
||||
ASSERT(0x010203ff, x);
|
||||
ASSERT(0x00000005, y);
|
||||
}
|
||||
|
||||
void testAugmentHiByte_onlyModifiesHigherBits(void) {
|
||||
int x, y;
|
||||
x = 0x01020304;
|
||||
y = 0x00000400;
|
||||
asm("sub\t%h1,%h0" : "+Q"(x) : "Q"(y));
|
||||
ASSERT(0x0102ff04, x);
|
||||
ASSERT(0x00000400, y);
|
||||
}
|
||||
|
||||
int main() {
|
||||
ASSERT(50, asm_fn1());
|
||||
ASSERT(55, asm_fn2());
|
||||
|
@ -135,5 +153,8 @@ int main() {
|
|||
ASSERT(1, !strcmp(p, "hello"));
|
||||
}
|
||||
|
||||
testAugmentLoByte_onlyModifiesLowerBits();
|
||||
testAugmentHiByte_onlyModifiesHigherBits();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue