Input completed.

This commit is contained in:
starcells committed 2026-05-04 16:00:49 +08:00
1 parent d7de27a54b
commit c6cce2a9a5
5 files changed
+29 -3

No files matched your search

+2
View File
@@ -14,6 +14,8 @@ typedef uint8_t rot8_ins_size;
// #define DATA_WIDTH (sizeof(rot8_data) * CHAR_BIT)
#define UNIT_SIZE 8 // Just for test.
#define ROT8_BC_TO_CHAR(bc) ("><+-[].,"[(bc)])
typedef enum {
STP, // Step Tape Pointer,'>'
BTP, // Back Tape Pointer,'<'
+2
View File
@@ -6,4 +6,6 @@
void rot8_out_io(rot8_iter *it);
void rot8_inp_io(rot8_iter *it);
void read_tape(const char *filename, char *tape);
#endif
+16
View File
@@ -1,6 +1,9 @@
#include "rot8/rot8_io.h"
#include <stdio.h>
#include <string.h>
#include "rot8/rot8.h"
void rot8_out_io(rot8_iter *it) {
// putchar(out(it));
@@ -11,3 +14,16 @@ void rot8_inp_io(rot8_iter *it) {
scanf("%d", &n);
inp(it, n);
}
void read_tape(const char *filename, char *tape) {
char *tail = tape;
FILE *fp = fopen(filename, "r");
char get;
while ((get = fgetc(fp)) != EOF) {
if (strchr("><+-[].,", get) != NULL) *tail = get;
tail++;
}
fclose(fp);
}
+1
View File
@@ -0,0 +1 @@
,>-+-+-+-+-+-+-+-+<>[<[-]+.>-+]<
+8 -3
View File
@@ -1,9 +1,14 @@
#include <stdlib.h>
#include <string.h>
#include "rot8/rot8.h"
#include "rot8/rot8_io.h"
int main(int argc, char **argv) {
(void)argc;
(void)argv;
char ins[] = ",>-+-+-+-+-+-+-+-+[<[-]+>-+]<";
run(ins, sizeof(ins) / sizeof(ins[0]) - 1);
char *ins = (char *)malloc(sizeof(char) * INS_SIZE);
read_tape(argv[1], ins);
run(ins, strlen(ins) - 1);
free(ins);
return (0);
}