summaryrefslogtreecommitdiff
path: root/sys/src/cmd/7l/asm.c
diff options
context:
space:
mode:
authorSigrid Solveig Haflínudóttir <sigrid@ftrv.se>2023-05-16 15:39:00 +0000
committerSigrid Solveig Haflínudóttir <sigrid@ftrv.se>2023-05-16 15:39:00 +0000
commitd4ce962fe33f3eca8da0b4ab2b5a81cc5359b71f (patch)
tree07d7ec1e80533b83d78dbd1838f701a8a56779c8 /sys/src/cmd/7l/asm.c
parent5e4b3a7490d301a7547a021bf1cf1e2d0f25de21 (diff)
7l: use floating point immediates where possible
Diffstat (limited to 'sys/src/cmd/7l/asm.c')
-rw-r--r--sys/src/cmd/7l/asm.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/sys/src/cmd/7l/asm.c b/sys/src/cmd/7l/asm.c
index 0b3b444fa..399a037b2 100644
--- a/sys/src/cmd/7l/asm.c
+++ b/sys/src/cmd/7l/asm.c
@@ -589,27 +589,17 @@ datblk(long s, long n, int str)
write(cout, buf.dbuf, n);
}
-static Ieee chipfloats[] = {
- {0x00000000, 0x00000000}, /* 0 */
- {0x00000000, 0x3ff00000}, /* 1 */
- {0x00000000, 0x40000000}, /* 2 */
- {0x00000000, 0x40080000}, /* 3 */
- {0x00000000, 0x40100000}, /* 4 */
- {0x00000000, 0x40140000}, /* 5 */
- {0x00000000, 0x3fe00000}, /* .5 */
- {0x00000000, 0x40240000}, /* 10 */
-};
-
int
chipfloat(Ieee *e)
{
- Ieee *p;
- int n;
-
- for(n = sizeof(chipfloats)/sizeof(chipfloats[0]); --n >= 0;){
- p = &chipfloats[n];
- if(p->l == e->l && p->h == e->h && 0)
- return n; /* TO DO: return imm8 encoding */
- }
- return -1;
+ int n, Bbbbbbbbb;
+
+ if(e->l != 0 || (e->h & 0xffffU) != 0)
+ return -1;
+ n = e->h >> 16;
+ Bbbbbbbbb = (n>>6) & 0x1ff;
+ if(Bbbbbbbbb != 0x100 && Bbbbbbbbb != 0xff)
+ return -1;
+ n = (n & 0x8000) >> 8 | (n & 0x7f);
+ return n;
}