commit 4231d51da9384a00934a82cb9c17815b356a068a
parent c27689dfdcd725246731d4f28a5548ff6818f43b
Author: Louis Burda <quent.burda@gmail.com>
Date: Wed, 4 Oct 2023 23:13:37 +0200
Fix port alphabet
Diffstat:
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/asm.c b/asm.c
@@ -11,6 +11,7 @@
#define TEXTALPH "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"
#define NUMALPH "0123456789"
+#define PORTALPH "abcdefghijklmnopqrstuvwxyz0123456789"
#define NAMEALPH TEXTALPH NUMALPH
#define WHITESPACE " \t\v\r\n,"
@@ -87,9 +88,11 @@ is_int(const char *str)
static int
asm_port_char_to_index(char c)
{
- if (!isalpha(c))
- die("invalid io port char '%c'", c);
- return tolower(c) - 'a';
+ char *p;
+
+ p = strchr(PORTALPH, tolower(c));
+ if (!p) die("invalid io port char '%c'", c);
+ return (int) (p - PORTALPH);
}
static bool
diff --git a/tpu.h b/tpu.h
@@ -9,7 +9,7 @@
#define LABEL_MAP_BUCKETS 64
#define TPU_MAX_INST_CNT 15
#define TPU_MAX_INST_LEN 18
-#define TIS_MAX_IO_PORTS 26
+#define TIS_MAX_IO_PORTS 36
/* enum order is important ! */
@@ -115,8 +115,8 @@ struct tpu_io_port {
struct tis {
struct tpu_map tpu_map;
- struct tpu_io_port *in_ports[26];
- struct tpu_io_port *out_ports[26];
+ struct tpu_io_port *in_ports[TIS_MAX_IO_PORTS];
+ struct tpu_io_port *out_ports[TIS_MAX_IO_PORTS];
};
void label_map_init(struct label_map *map);