Skip to content

Commit 3cebfc3

Browse files
committed
l8 53680
1 parent a6ec545 commit 3cebfc3

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

x/l8.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,15 @@ static void wl(ulong x){ //debug-only
2626
int i=31;while(x){s[--i]='0'+(x%10);x/=10;}
2727
swrite(1,s+i,32-i);}
2828

29-
extern char _end[];
30-
#define M_ _end
29+
static char*M_;
3130
#define I_ ((int*)M_)
3231
#define U_ ((ulong*)M_)
3332
static void*F_[]; //dispatch table
3433
#define int32_t int //some literals
3534
static ulong pages_=0;
3635
static int Memorysize(void){return pages_;}
37-
static int Memorygrow(int d){pages_+=d;if(pages_>16384)return -1;brk((pages_<<16)+(ulong)_end);return pages_-d;}
38-
static void Memory(int x){Memorygrow(x);wl(brk(0)-(long)_end);}
36+
static int Memorygrow(int d){pages_+=d;if(pages_>16384)return -1;brk((pages_<<16)+(ulong)M_);return pages_-d;}
37+
static void Memory(int x){M_=(char*)brk(0);Memorygrow(x);}
3938
static void Memory2(int x){}
4039

4140
//todo try/catch

x/mk

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ elif [ "$1" = "ctest" ]; then
2222
./kc ../k.t -e
2323
elif [ "$1" = "l8" ]; then
2424
k k.k cc.k -e 'x:`<cc``l8' > k.c
25-
gcc -Os -s -nostdlib -static -fomit-frame-pointer -Wl,--nmagic -Wl,--build-id=none -fno-asynchronous-unwind-tables -ol8 k.c
26-
#gcc -Wall -Wfatal-errors -Os -s -nostdlib -static -Wl,--nmagic -Wl,--build-id=none -fno-asynchronous-unwind-tables -ol8 k.c
27-
#gcc -Wall -Wfatal-errors -nostdlib -static -ol8 k.c -lm
25+
gcc -Os -s -nostdlib -static -Wl,--nmagic -Wl,--build-id=none -fno-asynchronous-unwind-tables -ol8_ k.c
26+
objcopy --remove-section .comment l8_ l8
2827
elif [ "$1" = "wa" ]; then
2928
k k.k wa.k -e 'x:`<wa``' > k.wa
3029
/c/local/wabt/wat2wasm k.wa

0 commit comments

Comments
 (0)