Skip to content

Commit fe9103d

Browse files
committed
Let's see.
1 parent bdbd3ec commit fe9103d

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

langs/mug/compile-ops.rkt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,16 @@
142142
(Add rdx 1) ; #words = 1 + (len+1)/2
143143
(Sar rdx 1)
144144
(Add rdx 1)
145-
(Sal rdx 3) ; #bytes = 8*#words
146-
(Mov r15 rbx) ; save what will be rax in non-volatile register
147-
(Add rbx rdx) ; increment before rdx is destroyed
145+
(Sal rdx 3) ; #bytes = 8*#words
146+
147+
(Mov 'r12 rdx) ; save rdx before destroyed
148148
pad-stack
149-
(Call 'memcpy)
149+
(Call 'my_memcpy)
150150
unpad-stack
151-
(Mov rax r15)))
151+
(Mov rbx rax) ; dst is returned, install as heap pointer
152+
(Add rbx 'r12)))
153+
154+
152155

153156
;; Op2 -> Asm
154157
(define (compile-op2 p)

langs/mug/compile.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@
4444
(Extern 'write_byte)
4545
(Extern 'raise_error)
4646
(Extern 'intern_symbol)
47-
(Extern 'memcpy)))
47+
(Extern 'my_memcpy)))

langs/mug/symbol.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#include <stdlib.h>
2+
#include <inttypes.h>
3+
#include <stdio.h>
4+
#include <string.h>
25
#include "values.h"
36

47
int symb_cmp(const val_symb_t *, const val_symb_t *);
@@ -12,6 +15,13 @@ struct Node {
1215

1316
static struct Node *symbol_tbl = NULL;
1417

18+
void *my_memcpy(void *dest, const void *src, size_t n) {
19+
printf("memcpy(%" PRId64 ", %" PRId64 ", %" PRId64 ")", (int64_t)dest, (int64_t)src, (int64_t)n);
20+
void * r = memcpy(dest, src, n);
21+
printf(" = %" PRId64 "\n", (int64_t)r);
22+
return r;
23+
}
24+
1525
val_symb_t *intern_symbol(val_symb_t* symb)
1626
{
1727
struct Node **curr = &symbol_tbl;

0 commit comments

Comments
 (0)