mirror of
https://github.com/pkivolowitz/asm_book.git
synced 2026-06-23 01:47:21 +08:00
Fix csel instruction use to match intended ternary operator
This commit is contained in:
parent
8e8c700b48
commit
89d8a1fe9b
1 changed files with 6 additions and 6 deletions
|
|
@ -503,9 +503,9 @@ FindOldestPerson: // 13
|
||||||
b 10f // enter loop // 20
|
b 10f // enter loop // 20
|
||||||
// 21
|
// 21
|
||||||
1: ldr w5, [x3, p.age] // fetch loop ptr -> age // 22
|
1: ldr w5, [x3, p.age] // fetch loop ptr -> age // 22
|
||||||
cmp w2, w5 // compare to oldest_age // 23
|
cmp w5, w2 // compare to oldest_age // 23
|
||||||
csel w2, w2, w5, gt // update based on cmp // 24
|
csel w2, w5, w2, gt // update based on cmp // 24
|
||||||
csel x0, x0, x3, gt // update based on cmp // 25
|
csel x0, x3, x0, gt // update based on cmp // 25
|
||||||
add x3, x3, 24 // increment loop ptr // 26
|
add x3, x3, 24 // increment loop ptr // 26
|
||||||
10: cmp x3, x4 // has loop ptr reached end_ptr? // 27
|
10: cmp x3, x4 // has loop ptr reached end_ptr? // 27
|
||||||
blt 1b // no, not yet // 28
|
blt 1b // no, not yet // 28
|
||||||
|
|
@ -670,15 +670,15 @@ resulted in a less than zero, zero, or more than zero result.
|
||||||
`Lines 24` and `25` read:
|
`Lines 24` and `25` read:
|
||||||
|
|
||||||
```asm
|
```asm
|
||||||
csel w2, w2, w5, gt // update based on cmp // 24
|
csel w2, w5, w2, gt // update based on cmp // 24
|
||||||
csel x0, x0, x3, gt // update based on cmp // 25
|
csel x0, x3, x0, gt // update based on cmp // 25
|
||||||
```
|
```
|
||||||
|
|
||||||
These are identical to this:
|
These are identical to this:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
w2 = (w5 > w2) ? w5 : w2;
|
w2 = (w5 > w2) ? w5 : w2;
|
||||||
x0 = (x5 > x2) ? x3 : x0;
|
x0 = (w5 > w2) ? x3 : x0;
|
||||||
```
|
```
|
||||||
|
|
||||||
**Remember that the condition or status bits have already been set based
|
**Remember that the condition or status bits have already been set based
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue