Skip to content

Commit 9c47e5f

Browse files
committed
Fixing let for mega
1 parent afe43d0 commit 9c47e5f

File tree

8 files changed

+20
-24
lines changed

8 files changed

+20
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ from other files in this repository. On linux systems, invoke `$ sudo make insta
3939
Usage
4040
-----
4141

42-
As of version 0.9.1, the usage is:
42+
As of version 0.9.2, the usage is:
4343

4444
```
4545
Usage: microscheme [-aucvrio] [-m model] [-d device] [-w filename] [-t rounds] program[.ms]

ffi_stuff/dump.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sys
55

66

7-
ser = serial.Serial(sys.argv[1], 1000000)
7+
ser = serial.Serial(sys.argv[1], 9600)
88
ser.flushInput()
99
ser.close()
1010

@@ -18,6 +18,4 @@
1818

1919
while 1:
2020
b1 = ser.read()
21-
b2 = ser.read()
22-
val = (ord(b1) << 8) + ord(b2)
23-
print (str(val))
21+
print (str(b1))

src/codegen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ void codegen_emit(AST_expr *expr, int parent_numArgs, FILE *outputFile) {
437437
}
438438

439439
else if (strcmp(expr->primproc, "stacksize") == 0 && expr->numBody == 0) {
440-
fprintf(outputFile, "\tIN GP1, SPl\n\tIN GP2, SPh\n\tLDI CRSl, lo8(RAMEND)\n\tLDI CRSh, hi8(RAMEND)\n\tSUB CRSl, GP1\n\tSBC CRSh, GP2\n");
440+
fprintf(outputFile, "\tIN GP1, SPl\n\tIN GP2, SPh\n\tLDI CRSl, lo8(__stack)\n\tLDI CRSh, hi8(__stack)\n\tSUB CRSl, GP1\n\tSBC CRSh, GP2\n");
441441
}
442442

443443
else if (strcmp(expr->primproc, "heapsize") == 0 && expr->numBody == 0) {

src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ int main(int argc, char *argv[]) {
6262
char *inname, *outname, *basename, *shortbase;
6363
int c;
6464

65-
fprintf(stdout, "Microscheme 0.9.1, (C) Ryan Suchocki\n");
65+
fprintf(stdout, "Microscheme 0.9.2, (C) Ryan Suchocki\n");
6666

6767
char *helpmsg = "\nUsage: microscheme [-aucvrio] [-m model] [-d device] [-w filename] [-t rounds] program[.ms]\n\n"
6868
"Option flags:\n"

src/models.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ model_info models[] = {
2626
".EQU DDR13, 0x04 \n"
2727
".EQU P13, 7 \n"
2828

29+
// This is necessary to stay within 13-bit addresses!
30+
".EQU _ms_stack, 0x2000\n"
31+
2932
".EQU UDR0, 0xC6 \n"
3033
".EQU UBRR0H, 0xC5 \n"
3134
".EQU UBRR0L, 0xC4 \n"
@@ -52,6 +55,8 @@ model_info models[] = {
5255
".EQU DDR13, 0x04 \n"
5356
".EQU P13, 5 \n"
5457

58+
".EQU _ms_stack, __stack\n"
59+
5560
".EQU UDR0, 0xC6 \n"
5661
".EQU UBRR0H, 0xC5 \n"
5762
".EQU UBRR0L, 0xC4 \n"
@@ -77,6 +82,8 @@ model_info models[] = {
7782
".EQU PORT13, 0x08 \n"
7883
".EQU DDR13, 0x07 \n"
7984
".EQU P13, 7 \n"
85+
86+
".EQU _ms_stack, __stack\n"
8087
}
8188
};
8289

src/parser.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extern bool opt_verbose;
1515
extern char **globalIncludeList;
1616
extern int globalIncludeListN;
1717

18-
AST_expr *currentLambda = NULL, *tmpLambda = NULL;
18+
AST_expr *currentLambda = NULL;
1919

2020
void parser_initExpr(AST_expr *expr) {
2121
expr->type = Constant;
@@ -144,7 +144,7 @@ AST_expr *parser_parseExpr(lexer_tokenNode **token, int numTokens, bool topLevel
144144
exit(EXIT_FAILURE);
145145
}
146146

147-
tmpLambda = currentLambda;
147+
AST_expr *tmpLambda = currentLambda;
148148
currentLambda = result;
149149
result->numBody = innerNumTokens-2;
150150
result->body = try_malloc(sizeof(AST_expr*) * (innerNumTokens-2));

src/preamble.s

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,15 @@ LDI HFPl, lo8(_end)
7171
LDI HFPh, hi8(_end)
7272
LDI CCPl, 0
7373
LDI CCPh, 0
74-
LDI AFPl, lo8(__stack)
75-
LDI AFPh, hi8(__stack)
74+
LDI AFPl, lo8(_ms_stack)
75+
LDI AFPh, hi8(_ms_stack)
76+
77+
OUT SPl, AFPl
78+
OUT SPh, AFPh
7679

7780
SBI DDR13, P13
7881
CBI PORT13, P13
7982

80-
# ; Set Baud Rate registers
81-
# LDI GP1, hi8(BAUD_9600)
82-
# STS UBRR0H, GP1 ;; ..1H for mega 1
83-
# LDI GP1, lo8(BAUD_9600)
84-
# STS UBRR0L, GP1 ;; ..1L for mega 1
85-
86-
# ; Set control registers
87-
# CLR GP1
88-
# SBR GP1, TXENm
89-
# SBR GP1, RXENm
90-
# STS UCSR0B, GP1 ;; ..1B for mega 1
91-
9283
RJMP entry_point
9384

9485
proc_call:

src/stdlib.ms

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
#x109 #x109 #x23 #x23 #x23 #x23))
121121
(set! arduino-pins (vector 1 2 16 32 32 8 8 16 32 64 16 32 64 128 2 1 2 1 8 4 2 1 1 2 4
122122
8 16 32 64 128 128 64 32 16 8 4 2 1 128 4 2 1 128 64 32 16 8
123-
4 2 1 8 4 2 1 1 2 4 8 16 32 64 128 1 2 4 8 16 32 64 128))))
123+
4 2 1 8 4 2 1))))
124124

125125
(@if-model "UNO"
126126
(begin

0 commit comments

Comments
 (0)