-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4ebef3
commit 9b35714
Showing
8 changed files
with
49 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import print32 from './print32.br'; | ||
print32(0n); | ||
print32(1n); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import wasm fd_write: (i32, i32, i32, i32) => i32 from 'wasi_snapshot_preview1'; | ||
// TODO: Implement toString32 | ||
export const print32: Function = (value: i32): Void => { | ||
// Helper | ||
let writeCharacterCode: Function = (let pointer: i32, character: i32): i32 => { | ||
// Store Character | ||
@wasm.i32.store(pointer, character); | ||
// Add To The Index | ||
pointer++; | ||
// Return Pointer | ||
return(pointer); | ||
}; | ||
// Create String | ||
const basePointer: i32 = 0n; | ||
let pointer: i32 = @wasm.i32.add(basePointer, 8n); | ||
let length: i32 = 0n; | ||
// Handle String Conversion In toString | ||
if (@wasm.i32.eqz(value)) { | ||
pointer = writeCharacterCode(pointer, 48n); | ||
length++; | ||
}; | ||
// Write New Line | ||
pointer = writeCharacterCode(pointer, 10n); | ||
length++; | ||
// Store Iov Info | ||
@wasm.i32.store(basePointer, 8n); | ||
@wasm.i32.store(@wasm.i32.add(basePointer, 4n), length); | ||
// Write String | ||
fd_write(1n, 0n, 1n, 40n); | ||
}; |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters