X-Git-Url: http://git.subgeniuskitty.com/vvhitespace/.git/blobdiff_plain/3695b659af12996f07d40088bf175a083770d573..d63de3fa849451796c2381723d042f254d434670:/stdlib/heap.pvvs diff --git a/stdlib/heap.pvvs b/stdlib/heap.pvvs index 62a0216..131b141 100644 --- a/stdlib/heap.pvvs +++ b/stdlib/heap.pvvs @@ -4,11 +4,11 @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ Description: @ This function writes pattern into the memory locations: -@ startaddr -> startaddr+numbytes +@ startaddr -> startaddr+count @ Call Stack: @ pattern @ startaddr -@ numbytes <-- TOS +@ count <-- TOS @ Return Stack: @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ -16,7 +16,7 @@ NSSVTTSSSN | Mark: 11000 (memset) @ Prepare the stack for computation. @ Addr | Contents -@ 0 | numbytes +@ 0 | count @ 1 | startaddr @ 2 | pattern @@ -41,7 +41,7 @@ SSSTSN | PUSH 2 (ptr) TTT | LOAD TTS | STORE -@ Decrement and check for loop end condition numbytes == 0. +@ Decrement and check for loop end condition count == 0. SSSSN | PUSH 0 (ptr) TTT | LOAD SNS | DUP @@ -58,4 +58,103 @@ NSSVSSSTTSSSSSSSSSSTN | Mark: 00011000 00000001 SNN | DROP NTN | RTS +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +@ Description: +@ This function copies count+1 words from source to destination. +@ Call Stack: +@ source +@ destination +@ count <-- TOS +@ Return Stack: +@ +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +NSSVTTSSTN | Mark: 11001 (memcpy) + +@ Prepare the stack for computation. +@ Addr | Contents +@ 0 | count +@ 1 | destination +@ 2 | source + +SSSSN | PUSH 0 (ptr) +SNT | SWAP +TTS | STORE +SSSTN | PUSH 1 (ptr) +SNT | SWAP +TTS | STORE +SSSTSN | PUSH 2 (ptr) +SNT | SWAP +TTS | STORE + +@ Copy one word on each pass through this loop. +NSSVSSSTTSSTSSSSSSSSN | Mark: 00011001 00000000 +SSSTN | PUSH 1 (ptr) +TTT | LOAD +SSSSN | PUSH 0 (ptr) +TTT | LOAD +TSSS | ADD +SSSTSN | PUSH 2 (ptr) +TTT | LOAD +SSSSN | PUSH 0 (ptr) +TTT | LOAD +TSSS | ADD +TTT | LOAD +TTS | STORE + +@ Decrement and check for loop end conditions. +SSSSN | PUSH 0 (ptr) +TTT | LOAD +SNS | DUP +NTSSSSTTSSTSSSSSSSTN | BRZ > 00011001 00000001 +SSSTN | PUSH 1 +TSST | SUBTRACT +SSSSN | PUSH 0 (ptr) +SNT | SWAP +TTS | STORE +NSNSSSTTSSTSSSSSSSSN | JMP > 00011001 00000000 + +@ Clean up and return +NSSVSSSTTSSTSSSSSSSTN | Mark: 00011001 00000001 +SNN | DROP +NTN | RTS + +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +@ Description: +@ This function writes random words into the memory locations: +@ startaddr -> startaddr+count +@ Call Stack: +@ count +@ startaddr <-- TOS +@ Return Stack: +@ +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +NSSVTTSTSN | Mark: 11010 (memrand) +SSSSN | PUSH 0 (ptr) +SNT | SWAP +TTS | STORE + +@ Store random word into one memory location on each pass through this loop. +NSSVSSSTTSTSSSSSSSSSN | Mark: 00011010 00000000 +SNS | DUP +SSSSN | PUSH 0 (ptr) +TTT | LOAD +TSSS | ADD +NSTTSSSSN | JSR > 10000 (random) +TTS | STORE + +@ Decrement and check loop end conditions +SNS | DUP +NTSSSSTTSTSSSSSSSSTN | BRZ > 00011010 00000001 +SSSTN | PUSH 1 +TSST | SUBTRACT +NSNSSSTTSTSSSSSSSSSN | JMP > 00011010 00000000 + +NNN +@ Clean up and return +NSSVSSSTTSTSSSSSSSSTN | Mark: 00011010 00000001 +SNN | DROP +NTN | RTS + +#include + #endif