From 1cc3a6fb7594ef543cc49406000afe4e58ad46e9 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Thu, 1 Feb 2024 02:59:12 +0200 Subject: [PATCH] example code --- asm-scripts/assembly/index.ts | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/asm-scripts/assembly/index.ts b/asm-scripts/assembly/index.ts index f2ef72f..c72267e 100644 --- a/asm-scripts/assembly/index.ts +++ b/asm-scripts/assembly/index.ts @@ -1,27 +1,22 @@ @inline -function load_followers(): i32 { - return i32.load(0); +function load_lines_of_code(): u32 { + return load(0); } @inline -function load_stars(): i32 { - return i32.load(4); +function load_evaluated_years_of_experience(): u8 { + return load(4); } -@external("host", "print") -export declare function print(p: i32): void; +@inline +function load_number_of_prs(): u32 { + return load(5); +} export function calc(): i64 { - let followers = load_followers(); - let stars = load_stars(); - - - for (let i = 0; i < 8; i++) { - print(i32.load8_u(i)); - } - - print(followers); - print(stars); + let loc = load_lines_of_code(); + let prs = load_number_of_prs(); + let yoe = load_evaluated_years_of_experience(); - return followers + stars; + return yoe * prs + loc; } \ No newline at end of file