Skip to content

Changes ordering of CSEL and CMP to match ternary operator #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions section_1/regs/array11.s
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ FindOldestPerson:
b 10f // enter loop

1: ldr w5, [x3, p.age] // fetch loop ptr -> age
cmp w2, w5 // compare to oldest_age
csel w2, w2, w5, gt // update based on cmp
csel x0, x0, x3, gt // update based on cmp
cmp w5, w2 // compare to oldest_age
csel w2, w5, w2, gt // update based on cmp
csel x0, x3, x0, gt // update based on cmp
add x3, x3, 24 // increment loop ptr
10: cmp x3, x4 // has loop ptr reached end_ptr?
blt 1b // no, not yet
Expand Down
12 changes: 6 additions & 6 deletions section_1/regs/ldr.md
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,9 @@ FindOldestPerson: // 13
b 10f // enter loop // 20
// 21
1: ldr w5, [x3, p.age] // fetch loop ptr -> age // 22
cmp w2, w5 // compare to oldest_age // 23
csel w2, w2, w5, gt // update based on cmp // 24
csel x0, x0, x3, gt // update based on cmp // 25
cmp w5, w2 // compare to oldest_age // 23
csel w2, w5, w2, gt // update based on cmp // 24
csel x0, x3, x0, gt // update based on cmp // 25
add x3, x3, 24 // increment loop ptr // 26
10: cmp x3, x4 // has loop ptr reached end_ptr? // 27
blt 1b // no, not yet // 28
Expand Down Expand Up @@ -670,15 +670,15 @@ resulted in a less than zero, zero, or more than zero result.
`Lines 24` and `25` read:

```asm
csel w2, w2, w5, gt // update based on cmp // 24
csel x0, x0, x3, gt // update based on cmp // 25
csel w2, w5, w2, gt // update based on cmp // 24
csel x0, x3, x0, gt // update based on cmp // 25
```

These are identical to this:

```c
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
Expand Down
Binary file modified section_1/regs/ldr.pdf
Binary file not shown.