add line function to platform

This commit is contained in:
2021-12-11 23:56:46 +01:00
parent 72e977c4ba
commit 6f92fd8bb3
11 changed files with 99 additions and 13 deletions

View File

@@ -3,7 +3,7 @@ import "env.memory" memory(4);
global mut base_end: i32 = 0;
export fn load_uw8(module_size: i32) -> i32 {
let lazy version = ?0 - 1;
let lazy version = 0?0 - 1;
if version < 0 {
return module_size;
}
@@ -21,10 +21,10 @@ export fn load_uw8(module_size: i32) -> i32 {
let src = 0x1e001;
loop sections {
if src < module_end & (base_start >= base_end | ?src <= ?base_start) {
if src < module_end & (base_start >= base_end | src?0 <= base_start?0) {
let lazy length2 = copy_section(dest, src);
dest = dest + length2;
if base_start < base_end & ?src == ?base_start {
if base_start < base_end & src?0 == base_start?0 {
base_start = base_start + section_size(base_start);
}
src = src + length2;
@@ -47,7 +47,7 @@ fn section_size(ptr: i32) -> i32 {
let l = 0;
let shift = 0;
loop size {
let lazy b = ?p;
let lazy b = p?0;
l = l | ((b & 127) << shift);
shift = shift + 7;
p = p + 1;
@@ -65,7 +65,7 @@ fn copy_section(dest: i32, src: i32) -> i32 {
fn copy(dest: i32, src: i32, len: i32) {
if len > 0 {
loop bytes {
?(dest + (len := len - 1)) = ?(src + len);
(dest + (len := len - 1))?0 = (src + len)?0;
branch_if len: bytes
}
}
@@ -142,7 +142,7 @@ fn upkr_bit(context_index: i32) -> i32 {
loop refill {
if upkr_state < 1<<16 {
upkr_state = (upkr_state << 8) | ?upkr_src_ptr;
upkr_state = (upkr_state << 8) | upkr_src_ptr?0;
upkr_src_ptr = upkr_src_ptr + 1;
branch refill;
}