[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] tips-and-tricks.org: Update
From: |
Mohammad-Reza Nabipoor |
Subject: |
[PATCH] tips-and-tricks.org: Update |
Date: |
Mon, 31 Jan 2022 20:51:01 +0330 |
---
tips-and-tricks.org | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
Hi, Jose.
apache2 sent this patch for pokology. I'm sending it to your for review.
Thanks!
diff --git a/tips-and-tricks.org b/tips-and-tricks.org
index eab6924..5ca187d 100644
--- a/tips-and-tricks.org
+++ b/tips-and-tricks.org
@@ -80,6 +80,22 @@
: (poke) (BER_Variable_Contents @ 0#B).get_bytes
: [0x61UB,0x62UB,0x63UB,0x64UB,0x65UB]
+ Similar results can be achieved using the idiom of resolving the
+ element count using a function:
+
+ : type VC = struct
+ : {
+ : fun poff = (offset<int,1> x)offset<int,1>:
+ : {
+ : while((byte[2] @ 0 : x) != [0UB, 0UB]){ x+=1#B; }
+ : return x - 1#B;
+ : }
+ : byte[ poff(OFFSET) ] payload;
+ : byte[2] end == [0UB,0UB];
+ : };
+ : (poke) VC @ #b;
+ : VC {payload=[0x61UB,0x62UB,0x63UB,0x64UB,0x65UB],end=[0x0UB,0x0UB]}
+
* Sub-byte endianness swaps
Byte-endianness is typically handled quite transparently in poke by
--
2.34.1
- [PATCH] tips-and-tricks.org: Update,
Mohammad-Reza Nabipoor <=