| ohdave.com Equal parts Joe Diffie and Diffie-Hellman | dashboard | contact | blog | twitter |
|
RSA in JavaScript
The example below uses my 100% JavaScript multiple-precision math library. The encryption exponent is small-ish, making for faster encryption. Presumably, decryption would be handled on the server, where things aren't as slow. In a nutshell, here are the JavaScript files you need: Additionally, I wrote a Windows application that generates random keys for use with the JavaScript library. It even generates the JavaScript source code. Paste and go! Note: The RSA key generator application is written in Delphi 4, which is Object Pascal. This includes a re-implementation of the multiple-precision library and the Miller-Rabin test for primality. Keys are generated using Algorithm 8.1 from the Handbook of Applied Cryptography. However, the actual random-number generation is not particularly robust. I just use the built-in functions in Delphi, seeded from the system clock. If you want to get fancy, you should write a better random-number generator. |


@* * Copyright 2023 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *@ @import uk.gov.hmrc.cataloguefrontend.DateHelper._ @import uk.gov.hmrc.cataloguefrontend.connector.GitRepository @import uk.gov.hmrc.cataloguefrontend.connector.model.Version @( repositoryDetails: GitRepository, version : Option[Version] = None )


Page 1 of 1
Reasons for a skills-based game
Posted:
Tue Mar 07, 2006 11:21 pm
by Karl G.
A thought occured to me about our character advancement system. If we have a graded skills system--where skills, spells and the like increase gradually--it may give Born to Rule a better overall feel than if a strict level system were used.
For example, getting the next level of a skill or higher spell for attaining a level brings a myriad of benefits simultaneously, thereby making the difference between a level 51 without those benefits and level 52 with them fairly large. However, if skills advance by expending experience points on them individually, a person who has attained level 51 and one at level 52 may have such diverse skill sets that they are closer in abilities.
I propose that when a character gains experience points, they may be "spent" on raising attributes or skills. The total amount of experience gained will be mostly for the purpose of being able to define the general ability a character should have.
Posted:
Wed Mar 08, 2006 7:53 am
by Joe M.
that's pretty much what I had in mind.
what I've been thinking is that a level will mean two things: raised mp/hp, bigger skill caps. Then all skills be based on use, and going down with disuse.
I'm not sure about assigning skill points versus skill points through advancement, though.
Maybe if you could assign skill points up to a certain point, different for each skill, and then you have to advance through use?
The problem with "buying" skills is that if you go out and bushwhack 108 skeletons, that shouldn't really make you better at brewing potions...
The problem with skills through use is evident in Xenimus--you don't know you're making progress, it leads to spamming of skill use and massive dumps of gold, and it's boring.
So I definitely see the point of having a skill buying system. I would like to see some skills-through-use, but maybe use that with martial skills, or just advance through use on all skills, but you can buy as well? or maybe successfully using a skill gives you some xp? (the problem there being that it raises your mp/hp to brew potions...)
I would lean toward a skill buying system, with successful use of skills giving a *small* amount of xp, and certain skills also advancing through use--most likely weapon skills.
what do y'all think?
Posted:
Wed Mar 08, 2006 4:35 pm
by Karl G.
Hmm I see that killing stuff really wouldn't make you better at doing things; and, conversely, doing stuff shouldn't make you stronger.
I think the system you described in which level affects HP, MP and skill caps whereas skill use affects their actual value would be best.
What about ability points, though? I'm talking basic strength, agility, etc. Should they simply be bestowed when the next level is achieved?
Posted:
Sun Apr 23, 2006 11:33 am
by Keats
Perhaps there could be a way to do that. Say you kill 100 skeletons with a sword and earn enough experience to upgrade. Since you got that experience through killing 100 skeletons with a sword you would be limited to upgrading things like strength, agility, etc. But if you killed those 100 skeletons with a potion that you created, you would be able to upgrade your potion skill, but not strength or agility.
Now, I have no ideas on how you'd implement this, that would be your department, Karl
Posted:
Sun Apr 23, 2006 10:42 pm
by Matt W.
good to see you again keats, your presence enlightens our boards
Posted:
Mon Apr 24, 2006 7:20 am
by Karl G.
Hey Keats! Great to see you!
That wouldn't be too hard to implement. Good idea
Any thoughts, Joe?
Posted:
Mon Apr 24, 2006 3:09 pm
by Joe M.
looks fine to me...
running out the door though. I'll give it a more thorough look-over later.
Posted:
Mon Apr 24, 2006 4:29 pm
by Keats
Hooray! I'm useful!
Posted:
Mon Apr 24, 2006 9:35 pm
by Joe M.
Keats--
looks like a fine idea. The only problem is the cycle you could get into: raise strength, get xp, raise strength, &c. You'd have a dog of a time getting out of it and expanding yourself.
A system along the same lines, but more limited, would be more player-friendly. If you aquire your XP with sword skills, you could raise your non-combat skills a little bit (maybe 10% of total gain could go toward non-relateds) and the rest would go toward combat-style skills.
Something like that.
2 cents of skill
Posted:
Tue Apr 25, 2006 10:49 pm
by Patrick
Karl's description and Joe's arguement sound a lot like a certain online game I played named Asheron's Call. Their idea was that each skill cost a certain amount of XP to raise to the next level, but by using the skill, you could reduce the cost to a more managable amount of XP. They also added the concept of specialized skills, which your character progesses in naturally more quickly (selected at character time, irreversible), and trained skills, which do not increase as quickly. Their idea was that level doesn't make a person more powerful, the wise use of XP on skills makes the person.
The benefit of that was that a level 50 could be beaten by a level 45 who spent more time improving his melee skills, or a level 10 warrior might be able to defeat a level 30 alchemist who doesn't know how to fight.
Oddly enough Fable had a way of solving the problem of killing a 100 monsters with an axe and increasing in alchemy skill, which was present in Asheron's Call. The basic of the idea is that you get points to distribute like Karl's idea, but the points are only effective to a certain degree: they increase only skills of the same class. For example, XP earned with an axe applies directly to any number of heavy headed weapons on a shaft, such as maces, hammers, axes, and perhaps spears, but not to something such as alchemy. At the same time, general XP, that is XP that is classless and spendable on any class, was also given. Perhaps you could add a conversion factor such as:
25 Melee XP -> 1 Alchemy XP.
to spice things up a bit, such that idiots can continue to hack away at skeletons and receive *some* benefit, as if perhaps they pondered on alchemy while they fought.
A more radical design was implemented in System Shock 2 and skill points are given for completing a quest, although in this case, it would be more appropriate to be done in a level-by-level basis like "Baldur's Gate: Dark Alliance". The idea is that you get these credits, more each time you level, to spend on skills that cost increasing amounts. For example:
* = 1 skill point, or whatever
Alchemy: ** cost = 3 credits
Axe: ***** cost = 15 credits
Trading: * cost = 1 credit
Next Level: 10 credits
Current: 8 credits
This can defeat the idea that using a skill does not equate to progressing in that skill since one can purchase upgrades.


Job {{ num_in_queue }} of {{ queue_length }} in queue
Job Complete
An error has occurred. Please check the output log. If no samples finished to completion, please abort the current run and try again. For help, please contact the interARTIC team on GitHub.
{{ numErrors }}
errors have occurred. Please check the output log. If no samples finished to completion, please abort the current run and try again. For help, please contact the interARTIC team on GitHub.


Hello {{user.username}},
We've successfully verified your sign up. You can now enjoy the full fetures of our website like posting blogs and a lot more.
Don't forget to subcribe to get latest blog posts
from: Sunny Blog, CEO
for more info or support kindly contact sunnyblog@gmail.com


alpinus population YNP data genetic species modern Fig evolutionary historic responses demographic range speciosus samples populations change temporal used changes genomic Biology migration Sciences observed recent climate frequency shifts using allele National additional alpinus, {border-style Click LINK century elevation file. DNA SNPs px;} structure #ffffff;} Life capture number selection environmental model time Population Tamias distribution histories history rapid sampled sampling University chipmunk models past (PDF) contraction demes effective increased site Alox D-SFS Evolutionary Molecular alpine best contrasts ecological fitting frequencies high individual positive potential rates sequencing However, Moritz associated chipmunks deme diversity montane nucleotide species. targeted ABC Ecology. Writing analyses bins change. estimates inference localities museum overall patterns results sequence variation California, Genetics Genome States Table Table). United collected distributions evidence expected gene genes inferred minimus versus Animal Ecology Evolution. Patton SFS Yosemite different exon joint local low point px; sample shown size sizes stable stress {font-family Fig). Nature. Proceedings Science. adaptive alpinus. ancient data. distance fitted font-size global hybridization individuals insights likelihood original outlier pooled populations. positions previous quality rate reads reduced represent response set simulated specimens speciosus, statistics strong transect values (XLSX) Bayesian Comparative Genetic Genomics Linderoth Nielsen Park SNP Sierra Temporal [], analysis archives base changing community comparative compared consistent contrast, coverage detect double; editing estimated fit following generate generated historical histories. indicated maximum oxidative posterior powerful reference related relatively review sequenced signatures simulations single small spanning spectrum study summary supported test understand < (–) ./nature America America. Annual Approximate Berkeley, Biology. Biology: California Climate Conceptualization Foundation Genetics. Good Methodology Resources Review Rubidge Society Southern Using archived based border-color border-width broadly change, co-distributed colleagues color conservation current detected developed did endemic evolution extent filtered flow fragmentation framework generation generations higher highly historic, increase mammal methods misincorporations mitochondrial morphology neutral novel outliers particular periods phenotypic provide provided relative represents resolution showed showing significant similar sites solid; specific type warming {font-style {font-weight (e.g., (i.e., (see ./mec. ./pnas. A). Academy American Bioinformatics. Craig Data Demographic Euclidean Evolution Genetics: Global Hammond Historic ML,obs Montana, Museum Research Research. Sierras Systematics. Table) Therefore, Thus, Trends Vanderpool adaptation allowed approach biological bold bottleneck closely clustered common comparisons complex connectivity considered contracted courier; damage declining demes. designed despite determine diet directional draft em; empirical enrichment environments. error estimate expansion explained extensive function functional future general genome-wide genotype habitat identified included increases independent infer introgression large led libraries loci lower metapopulations mid-elevation minimum nuclear null pairs pairwise parameter performed present previously prior probabilities protein providing pt;} ranges rapidly reductions regions remained replicates rescue role samples. snowpack spatial spatially speciosus) suggest support tested transects understanding vegetation winter


Welcome To JavaScript
Home
About
Portfolio
Blog
Kimi
No.
Name
Award
1
Harith Iskander
Gold
2
Jason Leong
Silver
3
Saiful Apek
Bronze
Assignment
Experiment:
80 Marks
20 Marks
Name
Question on:
SQL (25 marks)
PHP (25 marks)
JavaScript (50 marks)
Contribution of Total 25%
Final
Question
Topic
Marks
1
SQL
25
2
PHP
JavaScript
3
JavaScript
25
4
CSS
25
Contribution of total 25%


This is a totally optional page that doesn't affect your site functionality in any way. Filling out this survey helps the greater community of HOAs immensely! We anonymize the data (Make it impossible to link this data to you and your association) and use it to provide helpful research. Like knowing a normal range for annual dues. You can find a link to this page at the bottom of your settings page.


|
|
def | __init__ (self, List[str] terms) |
| |
|
Union[Dict[str, float], None] | tf_idf_for_term (self, str term) |
| |
|
dict | get_average_score_per_term (self, dict tfinfos) |
| |
|
dict | get_average_score_per_doc (self, dict tfinfos) |
| |
|
Dict[str, Dict[str, float]] | average_infos (self, dict tidf_infos) |
| |
|
def | search (self) |
| |
|
def | save_results (self) |
| |
|
|
| terms |
| |
|
| infos |
| |
|
| search_results |
| |
The documentation for this class was generated from the following file:
- agsearch/agsearch/tfidfinfo.py


Rutas
Your routes
Your routes
Conditions and services
Conditions and services
Policy and privacy
Policy and privacy
setting
setting
Language
Spanish
English


|
My Project
|
(Lightweight) emulation interface for executing PcodeOp objects within a syntax tree or for executing snippets defined with PcodeOpRaw objects More...
Go to the source code of this file.
Classes | |
| class | EmulatePcodeOp |
| Emulation based on (existing) PcodeOps and Varnodes. More... | |
| class | EmulateSnippet |
| Emulate a snippet of PcodeOps out of a functional context. More... | |
(Lightweight) emulation interface for executing PcodeOp objects within a syntax tree or for executing snippets defined with PcodeOpRaw objects


| Up | TOC | Index | |||||
| << 7 Included Tools | < 8.43 Pseudo Memory | Up: 8 API Reference | 8.46 Memory Constants > | 9 Release Notes >> |
8.44 Machine Level Access
<IP_ADDRESS> Marchine Level Access Summary
Warning: Some of these routines require a knowledge of machine-level programming. You could crash your system!
These routines, along with peek, poke and call, let you access all of the features of your computer. You can read and write to any allowed memory location, and you can create and execute machine code subroutines.
If you are manipulating 32-bit addresses or values, remember to use variables declared as atom. The integer type only goes up to 31 bits.
If you choose to call machine_proc or machine_func directly (to save a bit of overhead) you *must* pass valid arguments or Euphoria could crash.
Some example programs to look at:
- demo/callmach.ex -- calling a machine language routine
<IP_ADDRESS> peek_longs
include std/machine.e namespace machine public function peek_longs(object x)
@nodoc
<IP_ADDRESS> MAP_ANONYMOUS
include std/machine.e namespace machine export constant MAP_ANONYMOUS
<IP_ADDRESS> MAP_FAILED
include std/machine.e namespace machine export constant MAP_FAILED
8.44.1 Safe Mode
<IP_ADDRESS> Safe Mode Summary
During the development of your application, you can define the word SAFE to cause machine.e to use alternative memory functions. These functions are slower but help in the debugging stages. In general, SAFE mode should not be enabled during production phases but only for development phases.
To define the word SAFE run your application with the -D SAFE command line option, or add to the top of your main file:
with define safe
before the first appearance of include std/machine.e
The implementation of the Machine Level Access routines used are controled with the define word SAFE. The use of SAFE switches the routines included here to use debugging versions which will allow you to catch all kinds of bugs that might otherwise may not always crash your program where in the line your program is written. There may be bugs that are invisible until you port the program they are in to another platform. There has been no bench marking for how much of a speed penalty there is using SAFE.
You can take advantage of SAFE debugging by:
- If necessary, call register_block(address, length, memory_protection) to add additional "external" blocks of memory to the safe_address_list. These are blocks of memory that are safe to use but which you did not acquire through Euphoria's allocate, allocate_data, allocate_code or allocate_protect, allocate_string, allocate_wstring. Call unregister_block(address) when you want to prevent further access to an external block. When SAFE is not enabled these functions will do nothing and will be converted into nothing by the inline code in the front-end.
- You will be notified if memory that you haven't allocated is accessed, or if memory is freed twice, or if memory is used in the wrong way. Your application will can be ready for D.E.P. enabled systems even if the system you test on doesn't have D.E.P..
- If a bug is caught, you will hear some "beep" sounds. Press Enter to clear the screen and see the error message. There will be a descriptive crash message and a traceback in ex.err so you can find the statement that is making the illegal memory access.
<IP_ADDRESS> check_calls
Define block checking policy.
include std/machine.e public integer check_calls
Comments:
If this integer is 1, (the default), check all blocks for edge corruption after each Executable Memory, call, c_proc or c_func. To save time, your program can turn off this checking by setting check_calls to 0.
<IP_ADDRESS> edges_only
include std/machine.e public integer edges_only
Determine whether to flag accesses to remote memory areas.
Comments:
If this integer is 1 (the default under Windows), only check for references to the leader or trailer areas just outside each registered block, and don't complain about addresses that are far out of bounds (it's probably a legitimate block from another source)
For a stronger check, set this to 0 if your program will never read/write an unregistered block of memory.
On Windows people often use unregistered blocks. Please do not be one of them.
<IP_ADDRESS> check_all_blocks
include std/machine.e check_all_blocks()
Scans the list of registered blocks for any corruption.
Comments:
safe.e maintains a list of acquired memory blocks. Those gained through allocate are automatically included. Any other block, for debugging purposes, must be registered by register_block and unregistered by unregister_block.
The list is scanned and, if any block shows signs of corruption, it is displayed on the screen and the program terminates. Otherwise, nothing happens.
Unless SAFE is defined, this routine does nothing. It is there to make switching between debugged and normal version of your program easier.
See Also:
register_block, unregister_block
<IP_ADDRESS> register_block
include std/machine.e procedure register_block(machine_addr block_addr, positive_int block_len, valid_memory_protection_constant memory_protection = PAGE_READ_WRITE )
Adds a block of memory to the list of safe blocks maintained by safe.e (the debug version of memory.e). The block starts at address a. The length of the block is i bytes.
Parameters:
- block_addr : an atom, the start address of the block
- block_len : an integer, the size of the block.
- protection : a constant integer, of the memory protection constants found in machine.e, that describes what access we have to the memory.
Comments:
In memory.e, this procedure does nothing. It is there to simplify switching between the normal and debug version of the library.
This routine is only meant to be used for debugging purposes. safe.e tracks the blocks of memory that your program is allowed to peek, poke, mem_copy etc. These are normally just the blocks that you have allocated using Euphoria's allocate routine, and which you have not yet freed using Euphoria's free. In some cases, you may acquire additional, external, blocks of memory, perhaps as a result of calling a C routine.
If you are debugging your program using safe.e, you must register these external blocks of memory or safe.e will prevent you from accessing them. When you are finished using an external block you can unregister it using unregister_block.
Example 1:
atom addr addr = c_func(x, {}) register_block(addr, 5) poke(addr, "ABCDE") unregister_block(addr)
See Also:
<IP_ADDRESS> unregister_block
include std/machine.e public procedure unregister_block(machine_addr block_addr)
removes a block of memory from the list of safe blocks maintained by safe.e (the debug version of memory.e).
Parameters:
- block_addr : an atom, the start address of the block
Comments:
In memory.e, this procedure does nothing. It is there to simplify switching between the normal and debug version of the library.
This routine is only meant to be used for debugging purposes. Use it to unregister blocks of memory that you have previously registered using register_block. By unregistering a block, you remove it from the list of safe blocks maintained by safe.e. This prevents your program from performing any further reads or writes of memory within the block.
See register_block for further comments and an example.
See Also:
8.44.2 Data Execute Mode and Data Execute Protection
Data Execute Mode makes data that will be returned from allocate executable. On some systems you will not be allowed to run code in memory returned from allocate unless this mode has been enabled. This restriction is called Data Execute Protection or D.E.P.. When writing software you should use allocate_code or allocate_protect to get memory for execution. This is more efficient and more secure than using Data Execute mode. Because many hacker exploits of software use data buffers and then trick software into running this data, Data Execute Protection stops an entire class of exploits.
If you get a Data Execute Protection Exception from running software, it means that D.E.P. could have thwarted an attack! Your application crashes and your computer wasn't infected. However, many people will decide that they want to disable D.E.P. because they know that they call memory returned by allocate or perhaps they are simply careless.
8.44.3 Type Sorted Function List
<IP_ADDRESS> Executable Memory
Executable Memory is the way to run code on the stack in a completly portable way.
Use the following Routines:
Use allocate_code to allocate some executable machine-code, call to call the code, and free_code to free the machine-code.
<IP_ADDRESS> Using Data Bytes
In C, bytes are called 'char' or 'BOOL' or 'boolean'. They sometimes are used for very small numbers but mostly, they are used in C-strings. See Using Strings.
Use allocate_data to allocate data and return an address. Use poke to save atoms or sequences to at an address. Use peeks or peek to read from an address. Use mem_set and mem_copy to set and copy sections of memory. Use free to free or use delete if you enabled cleanup in allocate_data.
<IP_ADDRESS> Using Data Words
Words are 16-bit integers and are big enough to hold most integers in common use as far as whole numbers go. So they often are used to hold numbers. In C, they are declared as WORD or short.
Use allocate_data to allocate data and return its address. Use poke2 to write to the data at an address. Use peek2 or peek2s to read from an address. Use free to free or use delete if you enabled cleanup in allocate_data.
<IP_ADDRESS> Using Data Double Words
Double words are 32-bit integers. In C, they are typically declared as int, or long (on Windows and other 32-bit architectures), or DWORD. They are big enough to hold pointers to other values in memory on 32-bit architectures.
Use allocate_data to allocate data and return its address. Use poke4 to write to the data at an address. Use peek4 or peek4s to read from an address. Use free to free or use delete if you enabled cleanup in allocate_data.
<IP_ADDRESS> Using Data Quad Words
Quad words are 64-bit integers. In C, they are typically declared as long long int, or long int (on 64-bit architectures other than Windows). They are big enough to hold pointers to other values in memory on 64-bit architectures.
Use allocate_data to allocate data and return its address. Use poke8 to write to the data at an address. Use peek8u or peek8s to read from an address. Use free to free or use delete if you enabled cleanup in allocate_data.
<IP_ADDRESS> Using Pointers
A Euphoria atom should be used to store pointer values. On 32-bit architectures, pointers may be larger than a Euphoria integer. On 64-bit architectures, a Euphoria integer is large enough to hold pointer values, since current 64-bit architectures use only a 48-bit memory space
To portably peek and poke pointers, you should use peek_pointer and poke_pointer. These routines automatically detect the architecture and use the correct size for a pointer.
<IP_ADDRESS> Using Long Integers
When interfacing with C code, some data will be defined as long or long int. This data type can be tricky to use in a portable manner, due to the way that different architectures and operating systems define it.
On all 32-bit architectures on which Euphoria runs, a long int is defined as 32-bits. On 64-bit Windows, a long int is also 32-bits. However, on other 64-bit operating systems, a long int is defined as 64-bits.
To portably peek and poke long int data, you should use peek_longs, peek_longu and poke_long. You can also use sizeof( C_LONG ) to determine the size (in bytes) of a native long int.
<IP_ADDRESS> Using Strings
You can create legal ANSI and 16-bit UNICODE Strings with these routines. In C, strings are often declared as some pointer to a character: char * or wchar *.
Microsoft Windows uses 8-bit ANSI and 16-bit UNICODE in its routines.
Use allocate_string or allocate_wstring to allocate a string pointer. Use peek_string, peek_wstring, peek4, to read from memory byte strings, word strings and double word strings repsectively. Use poke, poke2, or poke4 to write to memory byte strings, word strings and double word strings. Use free to free or use delete if you enabled cleanup in allocate_data.
<IP_ADDRESS> Using Pointer Arrays
Use allocate_string_pointer_array to allocate a string array from a sequence of strings. Use allocate_pointer_array to allocate and then write to an array for pointers . Use free_pointer_array to deallocate or use delete if you enabled cleanup in allocate_data.
8.44.4 Memory Allocation
<IP_ADDRESS> allocate
include std/machine.e namespace machine public function allocate(memory :positive_int n, types :boolean cleanup = 0)
This does the same as allocate_data but allows the DATA_EXECUTE defined word to cause it to return executable memory.
See Also:
allocate_data, allocate_code, free
<IP_ADDRESS> allocate_data
include std/machine.e namespace machine public function allocate_data(memory :positive_int n, types :boolean cleanup = 0)
Allocate a contiguous block of data memory.
Parameters:
- n : a positive integer, the size of the requested block.
- cleanup : an integer, if non-zero, then the returned pointer will be automatically freed when its reference count drops to zero, or when passed as a parameter to delete.
Returns:
An atom, the address of the allocated memory or 0 if the memory can't be allocated. NOTE you must use either an atom or object to receive the returned value as sometimes the returned memory address is too larger for an integer to hold.
Comments:
- Since allocate acquires memory from the system, it is your responsiblity to return that memory when your application is done with it. There are two ways to do that - automatically or manually.
- Automatically - If the cleanup parameter is non-zero, then the memory is returned when the variable that receives the address goes out of scope and is not referenced by anything else. Alternatively you can force it be released by calling the delete function.
- Manually - If the cleanup parameter is zero, then you must call the free function at some point in your program to release the memory back to the system.
- When your program terminates, the operating system will reclaim all memory that your applicaiton acquired anyway.
- An address returned by this function shouldn't be passed to call. For that purpose you should use allocate_code instead.
- The address returned will be at least 8-byte aligned.
Example 1:
buffer = allocate(100) for i = 0 to 99 do poke(buffer+i, 0) end for
See Also:
Using Data Bytes, Using Data Words, Using Data Double Words, Using Strings, allocate_code, free
<IP_ADDRESS> allocate_pointer_array
include std/machine.e namespace machine public function allocate_pointer_array(sequence pointers, types :boolean cleanup = 0)
Allocate a NULL terminated pointer array.
Parameters:
- pointers : a sequence of pointers to add to the pointer array.
- cleanup : an integer, if non-zero, then the returned pointer will be automatically freed when its reference count drops to zero, or when passed as a parameter to delete
Comments:
This function adds the NULL terminator.
Example 1:
atom pa pa = allocate_pointer_array({ allocate_string("1"), allocate_string("2") })
See Also:
Using Pointer Arrays, allocate_string_pointer_array, free_pointer_array
<IP_ADDRESS> free_pointer_array
include std/machine.e namespace machine public procedure free_pointer_array(atom pointers_array)
Free a NULL terminated pointers array.
Parameters:
- pointers_array : memory address of where the NULL terminated array exists at.
Comments:
This is for NULL terminated lists, such as allocated by allocate_pointer_array. Do not call free_pointer_array for a pointer that was allocated to be cleaned up automatically. Instead, use delete.
See Also:
allocate_pointer_array, allocate_string_pointer_array
<IP_ADDRESS> allocate_string_pointer_array
include std/machine.e namespace machine public function allocate_string_pointer_array(object string_list, types :boolean cleanup = 0)
Allocate a C-style null-terminated array of strings in memory
Parameters:
- string_list : sequence of strings to store in RAM.
- cleanup : an integer, if non-zero, then the returned pointer will be automatically freed when its reference count drops to zero, or when passed as a parameter to delete
Returns:
An atom, the address of the memory block where the string pointer array was stored.
Example 1:
atom p = allocate_string_pointer_array({ "One", "Two", "Three" }) -- Same as C: char *p = { "One", "Two", "Three", NULL };
See Also:
Using Pointer Arrays, free_pointer_array
<IP_ADDRESS> allocate_wstring
include std/machine.e namespace machine public function allocate_wstring(sequence s, types :boolean cleanup = 0)
Create a C-style null-terminated wchar_t string in memory
Parameters:
- s : a unicode (utf16) string
Returns:
An atom, the address of the allocated string, or 0 on failure.
See Also:
Using Strings, allocate_string
8.44.5 Reading from Memory
<IP_ADDRESS> peek
<built-in> function peek(object addr_n_length)
fetches a byte, or some bytes, from an address in memory.
Parameters:
- addr_n_length : an object, either of
- an atom addr -- to fetch one byte at addr, or
- a pair {addr,len} -- to fetch len bytes at addr
Returns:
An object, either an integer if the input was a single address, or a sequence of integers if a sequence was passed. In both cases, integers returned are bytes, in the range 0..255.
Errors:
Peeking in memory you don't own may be blocked by the OS, and cause a machine exception. If you use the define safe these routines will catch these problems with a EUPHORIA error.
When supplying a {address, count} sequence, the count must not be negative.
Comments:
Since addresses are 32-bit numbers on 32-bit architectures, they can be larger than the largest value of type integer (31-bits). Variables that hold an address should therefore be declared as atoms.
It is faster to read several bytes at once using the second form of peek than it is to read one byte at a time in a loop. The returned sequence has the length you asked for on input.
Remember that peek takes just one argument, which in the second form is actually a 2-element sequence.
Example 1:
-- The following are equivalent: -- first way s = {peek(100), peek(101), peek(102), peek(103)} -- second way s = peek({100, 4})
See Also:
Using Data Bytes, poke, peeks, peek4u, allocate, free, peek2u
<IP_ADDRESS> peeks
<built-in> function peeks(object addr_n_length)
fetches a byte, or some bytes, from an address in memory.
Parameters:
- addr_n_length : an object, either of
- an atom addr : to fetch one byte at addr, or
- a pair {addr,len} : to fetch len bytes at addr
Returns:
An object, either an integer if the input was a single address, or a sequence of integers if a sequence was passed. In both cases, integers returned are bytes, in the range -128..127.
Errors:
Peeking in memory you do not own may be blocked by the OS, and cause a machine exception. If you use the define safe these routines will catch these problems with a Euphoria error.
When supplying a {address, count} sequence, the count must not be negative.
Comments:
Since addresses are 32-bit numbers on 32-bit architectures, they can be larger than the largest value of type integer (31-bits). Variables that hold an address should therefore be declared as atoms.
It is faster to read several bytes at once using the second form of peek than it is to read one byte at a time in a loop. The returned sequence has the length you asked for on input.
Remember that peeks takes just one argument, which in the second form is actually a 2-element sequence.
Example 1:
-- The following are equivalent: -- first way s = {peeks(100), peek(101), peek(102), peek(103)} -- second way s = peeks({100, 4})
See Also:
Using Data Bytes, poke, peek4s, allocate, free, peek2s, peek
<IP_ADDRESS> peek2s
<built-in> function peek2s(object addr_n_length)
Fetches a signed word, or some signed words , from an address in memory.
Parameters:
- addr_n_length : an object, either of
- an atom addr -- to fetch one word at addr, or
- a pair { addr, len}, to fetch len words at addr
Returns:
An object, either an integer if the input was a single address, or a sequence of integers if a sequence was passed. In both cases, integers returned are double words, in the range -32768..32767.
Errors:
Peeking in memory you don't own may be blocked by the OS, and cause a machine exception. If you use the define safe these routines will catch these problems with a EUPHORIA error.
When supplying a {address, count} sequence, the count must not be negative.
Comments:
Since addresses are 32-bit numbers on 32-bit architectures, they can be larger than the largest value of type integer (31-bits). Variables that hold an address should therefore be declared as atoms.
It is faster to read several words at once using the second form of peek than it is to read one word at a time in a loop. The returned sequence has the length you asked for on input.
Remember that peek2s takes just one argument, which in the second form is actually a 2-element sequence.
The only difference between peek2s and peek2u is how words with the highest bit set are returned. peek2s assumes them to be negative, while peek2u just assumes them to be large and positive.
Example 1:
-- The following are equivalent: -- first way s = {peek2s(100), peek2s(102), peek2s(104), peek2s(106)} -- second way s = peek2s({100, 4})
See Also:
Using Data Words, poke2, peeks, peek4s, allocate, free peek2u
<IP_ADDRESS> peek2u
<built-in> function peek2u(object addr_n_length)
fetches an unsigned word, or some unsigned words, from an address in memory.
Parameters:
- addr_n_length : an object, either of
- an atom addr -- to fetch one double word at addr, or
- a pair {addr,len} -- to fetch len double words at addr
Returns:
An object, either an integer if the input was a single address, or a sequence of integers if a sequence was passed. In both cases, integers returned are words, in the range 0..65535.
Errors:
Peeking in memory you do not own may be blocked by the OS, and cause a machine exception. If you use the define safe these routines will catch these problems with a Euphoria error.
When supplying a {address, count} sequence, the count must not be negative.
Comments:
Since addresses are 32-bit numbers on 32-bit architectures, they can be larger than the largest value of type integer (31-bits). Variables that hold an address should therefore be declared as atoms.
It is faster to read several words at once using the second form of peek than it is to read one word at a time in a loop. The returned sequence has the length you asked for on input.
Remember that peek2u takes just one argument, which in the second form is actually a 2-element sequence.
The only difference between peek2s and peek2u is how words with the highest bit set are returned. peek2s assumes them to be negative, while peek2u just assumes them to be large and positive.
Example 1:
-- The following are equivalent: -- first way Get 4 2-byte numbers starting address 100. s = {peek2u(100), peek2u(102), peek2u(104), peek2u(106)} -- second way Get 4 2-byte numbers starting address 100. s = peek2u({100, 4})
See Also:
Using Data Words, poke2, peek, peek2s, allocate, free peek4u
<IP_ADDRESS> peek4s
<built-in> function peek4s(object addr_n_length)
fetches a signed double words, or some signed double words, from an address in memory.
Parameters:
- addr_n_length : an object, either of
- an atom addr -- to fetch one double word at addr, or
- a pair { addr, len } -- to fetch len double words at addr
Returns:
An object, either an atom if the input was a single address, or a sequence of atoms if a sequence was passed. In both cases, atoms returned are double words, in the range -(231)..231-1.
Errors:
Peeking in memory you don't own may be blocked by the OS, and cause a machine exception. If you use the define safe these routines will catch these problems with a Euphoria error.
When supplying a {address, count} sequence, the count must not be negative.
Comments:
Since addresses are 32-bit numbers on 32-bit architectures, they can be larger than the largest value of type integer (31-bits). Variables that hold an address should therefore be declared as atoms.
It is faster to read several double words at once using the second form of peek than it is to read one double word at a time in a loop. The returned sequence has the length you asked for on input.
Remember that peek4s takes just one argument, which in the second form is actually a 2-element sequence.
The only difference between peek4s and peek4u is how double words with the highest bit set are returned. peek4s assumes them to be negative, while peek4u just assumes them to be large and positive.
Example 1:
-- The following are equivalent: -- first way s = {peek4s(100), peek4s(104), peek4s(108), peek4s(112)} -- second way s = peek4s({100, 4})
See Also:
Using Data Double Words, poke4, peeks, peek4u, allocate, free, peek2s
<IP_ADDRESS> peek8s
<built-in> function peek8s(object addr_n_length)
fetches a signed quad words, or some signed quad words, from an address in memory.
Parameters:
- addr_n_length : an object, either of
- an atom addr -- to fetch one double word at addr, or
- a pair { addr, len } -- to fetch len quad words at addr
Returns:
An object, either an atom if the input was a single address, or a sequence of atoms if a sequence was passed. In both cases, atoms returned are quad words, in the range -power(2,63)..power(2,63)-1.
Errors:
Peeking in memory you don't own may be blocked by the OS, and cause a machine exception. If you use the define safe these routines will catch these problems with a Euphoria error.
When supplying a {address, count} sequence, the count must not be negative.
Comments:
Since addresses are 32-bit numbers on 32-bit architectures, they can be larger than the largest value of type integer (31-bits). Variables that hold an address should therefore be declared as atoms.
It is faster to read several quad words at once using the second form of peek than it is to read one quad word at a time in a loop. The returned sequence has the length you asked for on input.
Remember that peek8s takes just one argument, which in the second form is actually a 2-element sequence.
The only difference between peek8s and peek8u is how quad words with the highest bit set are returned. peek4s assumes them to be negative, while peek4u just assumes them to be large and positive.
Example 1:
-- The following are equivalent: -- first way s = {peek8s(100), peek8s(108), peek8s(116), peek8s(124)} -- second way s = peek8s({100, 4})
See Also:
Using Data Double Words, poke4, peeks, peek4u, allocate, free, peek2s
<IP_ADDRESS> peek4u
<built-in> function peek4u(object addr_n_length)
fetches an unsigned double word, or some unsigned double words, from an address in memory.
Parameters:
- addr_n_length : an object, either of
- an atom addr -- to fetch one double word at addr, or
- a pair {addr,len} -- to fetch len double words at addr
Returns:
An object, either an atom if the input was a single address, or a sequence of atoms if a sequence was passed. In both cases, atoms returned are double words, in the range 0..232-1.
Errors:
Peeking in memory you do not own may be blocked by the OS, and cause a machine exception. If you use the define safe these routines will catch these problems with a Euphoria error.
When supplying a {address, count} sequence, the count must not be negative.
Comments:
Since addresses are 32-bit numbers on 32-bit architectures, they can be larger than the largest value of type integer (31-bits). Variables that hold an address should therefore be declared as atoms.
It is faster to read several double words at once using the second form of peek than it is to read one double word at a time in a loop. The returned sequence has the length you asked for on input.
Remember that peek4u takes just one argument, which in the second form is actually a 2-element sequence.
The only difference between peek4s and peek4u is how double words with the highest bit set are returned. peek4s assumes them to be negative, while peek4u just assumes them to be large and positive.
Example 1:
-- The following are equivalent: -- first way s = {peek4u(100), peek4u(104), peek4u(108), peek4u(112)} -- second way s = peek4u({100, 4})
See Also:
Using Data Double Words, poke4, peek, peek4s, allocate, free, peek2u
<IP_ADDRESS> peek8u
<built-in> function peek8u(object addr_n_length)
fetches an unsigned quad word, or some unsigned quad words, from an address in memory.
Parameters:
- addr_n_length : an object, either of
- an atom addr -- to fetch one double word at addr, or
- a pair {addr,len} -- to fetch len double words at addr
Returns:
An object, either an atom if the input was a single address, or a sequence of atoms if a sequence was passed. In both cases, atoms returned are quad words, in the range 0..power(2,64)-1.
Errors:
Peeking in memory you do not own may be blocked by the OS, and cause a machine exception. If you use the define safe these routines will catch these problems with a Euphoria error.
When supplying a {address, count} sequence, the count must not be negative.
Comments:
Since addresses are 32-bit numbers on 32-bit architectures, they can be larger than the largest value of type integer (31-bits). Variables that hold an address should therefore be declared as atoms.
It is faster to read several quad words at once using the second form of peek than it is to read one quad word at a time in a loop. The returned sequence has the length you asked for on input.
Remember that peek8u takes just one argument, which in the second form is actually a 2-element sequence.
The only difference between peek8s and peek8u is how quad words with the highest bit set are returned. peek8s assumes them to be negative, while peek8u just assumes them to be large and positive.
Example 1:
-- The following are equivalent: --first way s = {peek8u(100), peek8u(108), peek8u(116), peek8u(124)} -- second way s = peek8u({100, 4})
See Also:
Using Data Double Words, poke4, peek, peek4s, allocate, free, peek2u
<IP_ADDRESS> peek_longu
<built-in> function peek_longu(object addr_n_length)
fetches an unsigned integer, or some unsigned integers, from an address in memory.
Parameters:
- addr_n_length : an object, either of
- an atom addr -- to fetch one double word at addr, or
- a pair {addr,len} -- to fetch len double words at addr
Returns:
An object, either an atom if the input was a single address, or a sequence of atoms if a sequence was passed. In both cases, atoms returned are based on the native size of a "long int." On Windows and all other 32-bit architectures, the number will be in the range 0..power(2,32)-1. On other 64-bit architectures, the number will be in the range of 0..power(2,64)-1.
Errors:
Peeking in memory you do not own may be blocked by the OS, and cause a machine exception. If you use the define safe these routines will catch these problems with a Euphoria error.
When supplying a {address, count} sequence, the count must not be negative.
Comments:
Since addresses are 32-bit numbers on 32-bit architectures, they can be larger than the largest value of type integer (31-bits). Variables that hold an address should therefore be declared as atoms.
It is faster to read several integers at once using the second form of peek than it is to read one integer at a time in a loop. The returned sequence has the length you asked for on input.
Remember that peek_longu takes just one argument, which in the second form is actually a 2-element sequence.
The only difference between peek_longs and peek_longu is how double words with the highest bit set are returned. peek4s assumes them to be negative, while peek_longu just assumes them to be large and positive.
Example 1:
-- The following are equivalent (on a 32-bit architecture, or Windows): -- first way s = {peek_longu(100), peek4u(104), peek4u(108), peek4u(112)} -- second way s = peek_longu({100, 4})
See Also:
Using Data Double Words, poke4, peek, peek4s, allocate, free, peek2u, peek2s, peek8u, peek8s, peek_longs, poke_long
<IP_ADDRESS> peek_string
<built-in> function peek_string(atom addr)
reads an ASCII string in RAM, starting from a supplied address.
Parameters:
- addr : an atom, the address at which to start reading.
Returns:
A sequence, of bytes, the string that could be read.
Errors:
Further, peeking in memory that does not belong to your process is something the operating system could prevent, and you'd crash with a machine level exception.
Comments:
An ASCII string is any sequence of bytes and ends with a 0 byte. If you peek_string at some place where there is no string, you will get a sequence of garbage.
See Also:
Using Strings, peek, peek_wstring, allocate_string
<IP_ADDRESS> peek_pointer
<built-in> function peek_pointer(object addr_n_length)
<IP_ADDRESS> peek_wstring
include std/machine.e namespace machine public function peek_wstring(atom addr)
returns a unicode (utf16) string that are stored at machine address a.
Parameters:
- addr : an atom, the address of the string in memory
Returns:
The string, at the memory position. The terminator is the null word (two bytes equal to 0).
See Also:
8.44.6 Writing to Memory
<IP_ADDRESS> poke
<built-in> procedure poke(atom addr, object x)
stores one or more bytes, starting at a memory location.
Parameters:
- addr : an atom, the address at which to store
- x : an object, either a byte or a non empty sequence of bytes.
Errors:
Poking in memory you do not own may be blocked by the OS, and cause a machine exception. The -D SAFE option will make poke catch this sort of issues.
Comments:
The lower 8-bits of each byte value (such as remainder(x, 256)) is actually stored in memory.
It is faster to write several bytes at once by poking a sequence of values, than it is to write one byte at a time in a loop.
Writing to the screen memory with poke can be much faster than using puts or printf, but the programming is more difficult. In most cases the speed is not needed. For example, the Euphoria editor, ed, never uses poke.
Example 1:
a = allocate(100) -- allocate 100 bytes in memory -- poke one byte at a time: poke(a, 97) poke(a+1, 98) poke(a+2, 99) -- poke 3 bytes at once: poke(a, {97, 98, 99})
Example 2:
demo/callmach.ex
See Also:
Using Data Bytes, peek, peeks, poke4, allocate, free, poke2, mem_copy, mem_set
<IP_ADDRESS> poke2
<built-in> procedure poke2(atom addr, object x)
stores one or more words, starting at a memory location.
Parameters:
- addr : an atom, the address at which to store
- x : an object, either a word or a non empty sequence of words.
Errors:
Poking in memory you do not own may be blocked by the OS, and cause a machine exception. If you use the define safe these routines will catch these problems with a Euphoria error.
Comments:
There is no point in having poke2s or poke2u. For example, both 32768 and -32768 are stored as #F000 when stored as words. It is up to whoever reads the value to figure it out.
It is faster to write several words at once by poking a sequence of values, than it is to write one words at a time in a loop.
Writing to the screen memory with poke2 can be much faster than using puts or printf, but the programming is more difficult. In most cases the speed is not needed. For example, the Euphoria editor, ed, never uses poke2.
The 2-byte values to be stored can be negative or positive. You can read them back with either peek2s or peek2u. Actually, only remainder(x,65536) is being stored.
Example 1:
a = allocate(100) -- allocate 100 bytes in memory -- poke one 2-byte value at a time: poke2(a, 12345) poke2(a+2, #FF00) poke2(a+4, -12345) -- poke 3 2-byte values at once: poke2(a, {12345, #FF00, -12345})
See Also:
Using Data Words, peek2s, peek2u, poke, poke4, allocate, free
<IP_ADDRESS> poke4
<built-in> procedure poke4(atom addr, object x)
stores one or more double words, starting at a memory location.
Parameters:
- addr : an atom, the address at which to store
- x : an object, either a double word or a non empty sequence of double words.
Errors:
Poking in memory you do not own may be blocked by the OS, and cause a machine exception. If you use the define safe these routines will catch these problems with a Euphoria error.
Comments:
There is no point in having poke4s or poke4u. For example, both +231 and -(231) are stored as #F0000000. It is up to whoever reads the value to figure it out.
It is faster to write several double words at once by poking a sequence of values, than it is to write one double words at a time in a loop.
Writing to the screen memory with poke4 can be much faster than using puts or printf, but the programming is more difficult. In most cases the speed is not needed. For example, the Euphoria editor, ed, never uses poke4.
The 4-byte values to be stored can be negative or positive. You can read them back with either peek4s or peek4u. However, the results are unpredictable if you want to store values with a fractional part or a magnitude greater than 232, even though Euphoria represents them all as atoms.
Example 1:
a = allocate(100) -- allocate 100 bytes in memory -- poke one 4-byte value at a time: poke4(a, 9712345) poke4(a+4, #FF00FF00) poke4(a+8, -12345) -- poke 3 4-byte values at once: poke4(a, {9712345, #FF00FF00, -12345})
See Also:
Using Data Double Words, peek4s, peek4u, poke, poke2, allocate, free, call
<IP_ADDRESS> poke8
<built-in> procedure poke8(atom addr, object x)
stores one or more quad words, starting at a memory location.
Parameters:
- addr : an atom, the address at which to store
- x : an object, either a quad word or a non empty sequence of double words.
Errors:
Poking in memory you do not own may be blocked by the OS, and cause a machine exception. If you use the define safe these routines will catch these problems with a Euphoria error.
Comments:
There is no point in having poke8s or poke8u. For example, both +power(2,63) and -power(2,63) are stored as #F000000000000000. It is up to whoever reads the value to figure it out.
It is faster to write several quad words at once by poking a sequence of values, than it is to write one quad words at a time in a loop.
The 8-byte values to be stored can be negative or positive. You can read them back with either peek8s or peek8u. However, the results are unpredictable if you want to store values with a fractional part or a magnitude greater than power(2,64), even though Euphoria represents them all as atoms.
Example 1:
a = allocate(100) -- allocate 100 bytes in memory -- poke one 8-byte value at a time: poke8(a, 9712345) poke8(a+8, #FF00FF00) poke8(a+16, -12345) -- poke 3 8-byte values at once: poke8(a, {9712345, #FF00FF00, -12345})
See Also:
Using Data Double Words, peek4s, peek4u, poke, poke2, allocate, free, call
<IP_ADDRESS> poke_long
<built-in> procedure poke_long(atom addr, object x)
stores one or more integers, starting at a memory location.
Parameters:
- addr : an atom, the address at which to store
- x : an object, either an integer or a non empty sequence of double words.
Errors:
Poking in memory you do not own may be blocked by the OS, and cause a machine exception. If you use the define safe these routines will catch these problems with a Euphoria error.
Comments:
There is no point in having poke_longs or poke_longu. For example, both +power(2,31) and -power(2,31) are stored as #F0000000 on a 32-bit architecture. It is up to whoever reads the value to figure it out.
On all Windows and other 32-bit operating systems, the poke_long uses 4-byte integers. On 64-bit architectures using operating systems other than Windows, poke_long uses 8-byte integers.
It is faster to write several integers at once by poking a sequence of values, than it is to write one double words at a time in a loop.
The 4-byte (or 8-byte) values to be stored can be negative or positive. You can read them back with either peek_longs or peek_longu. However, the results are unpredictable if you want to store values with a fractional part or a magnitude greater than the size of a native long int, even though Euphoria represents them all as atoms.
Example 1:
a = allocate(100) -- allocate 100 bytes in memory -- poke one 4-byte value at a time (on Windows or other 32-bit operating system): poke_long(a, 9712345) poke_long(a+4, #FF00FF00) poke_long(a+8, -12345) -- poke 3 long int values at once: poke_long(a, {9712345, #FF00FF00, -12345})
See Also:
Using Data Double Words, peek4s, peek4u, poke, poke2, allocate, free, call
<IP_ADDRESS> poke_pointer
<built-in> procedure poke_pointer(atom addr, object x)
stores one or more pointers, starting at a memory location.
Parameters:
- addr : an atom, the address at which to store
- x : an object, either an integer or a non empty sequence of pointers.
Errors:
Poking in memory you do not own may be blocked by the OS, and cause a machine exception. If you use the define safe these routines will catch these problems with a Euphoria error.
Comments:
There is no point in having poke_pointers or poke_pointersu. For example, both +power(2,31) and -power(2,31) are stored as #F0000000 on a 32-bit architecture. It is up to whoever reads the value to figure it out.
On all 32-bit operating systems, the poke_pointer uses 4-byte integers. On 64-bit architectures using operating systems, poke_pointer uses 8-byte integers.
It is faster to write several pointers at once by poking a sequence of values, than it is to write one double words at a time in a loop.
The 4-byte (or 8-byte) values to be stored can be negative or positive. You can read them back with either peek_pointer or any other peek function of the correctsize. However, the results are unpredictable if you want to store values with a fractional part or a magnitude greater than the size of a native pointer, even though Euphoria represents them all as atoms.
Example 1:
a = allocate(100) -- allocate 100 bytes in memory -- poke one 4-byte value at a time (on a 32-bit operating system): poke_pointer(a, 9712345) poke_pointer(a+4, #FF00FF00) poke_pointer(a+8, -12345) -- poke 3 long int values at once: poke_pointer(a, {9712345, #FF00FF00, -12345})
See Also:
Using Data Double Words, peek4s, peek4u, peek8u, peek8s, peek_pointer poke, poke2, allocate, free, call
<IP_ADDRESS> poke_string
include std/machine.e namespace machine public function poke_string(atom buffaddr, integer buffsize, sequence s)
Stores a C-style null-terminated ANSI string in memory
Parameters:
- buffaddr: an atom, the RAM address to to the string at.
- buffsize: an integer, the number of bytes available, starting from buffaddr.
- s : a sequence, the string to store at address buffaddr.
Comments:
- This does not allocate an RAM. You must supply the preallocated area.
- This can only be used on ANSI strings. It cannot be used for double-byte strings.
- If s is not a string, nothing is stored and a zero is returned.
Returns:
An atom. If this is zero, then nothing was stored, otherwise it is the address of the first byte after the stored string.
Example 1:
atom title title = allocate(1000) if poke_string(title, 1000, "The Wizard of Oz") then -- successful else -- failed end if
See Also:
Using Strings, allocate, allocate_string
<IP_ADDRESS> poke_wstring
include std/machine.e namespace machine public function poke_wstring(atom buffaddr, integer buffsize, sequence s)
stores a C-style null-terminated Double-Byte string in memory.
Parameters:
- buffaddr: an atom, the RAM address to to the string at.
- buffsize: an integer, the number of bytes available, starting from buffaddr.
- s : a sequence, the string to store at address buffaddr.
Comments:
- This does not allocate an RAM. You must supply the preallocated area.
- This uses two bytes per string character. Note that buffsize is the number of bytes available in the buffer and not the number of characters available.
- If s is not a double-byte string, nothing is stored and a zero is returned.
Returns:
An atom. If this is zero, then nothing was stored, otherwise it is the address of the first byte after the stored string.
Example 1:
atom title title = allocate(1000) if poke_wstring(title, 1000, "The Wizard of Oz") then -- successful else -- failed end if
See Also:
Using Strings, allocate, allocate_wstring
8.44.7 Memory Manipulation
<IP_ADDRESS> mem_copy
<built-in> procedure mem_copy(atom destination, atom origin, integer len)
copies a block of memory from an address to another.
Parameters:
- destination : an atom, the address at which data is to be copied
- origin : an atom, the address from which data is to be copied
- len : an integer, how many bytes are to be copied.
Comments:
The bytes of memory will be copied correctly even if the block of memory at destination overlaps with the block of memory at origin.
mem_copy(destination, origin, len) is equivalent to: poke(destination, peek({origin, len})) but is much faster.
Example 1:
dest = allocate(50) src = allocate(100) poke(src, {1,2,3,4,5,6,7,8,9}) mem_copy(dest, src, 9)
See Also:
Using Data Bytes, mem_set, peek, poke, allocate, free
<IP_ADDRESS> mem_set
<built-in> procedure mem_set(atom destination, integer byte_value, integer how_many))
sets a contiguous range of memory locations to a single value.
Parameters:
- destination : an atom, the address starting the range to set.
- byte_value : an integer, the value to copy at all addresses in the range.
- how_many : an integer, how many bytes are to be set.
Comments:
The low order 8 bits of byte_value are actually stored in each byte. mem_set(destination, byte_value, how_many) is equivalent to: poke(destination, repeat(byte_value, how_many)) but is much faster.
Example 1:
destination = allocate(1000) mem_set(destination, ' ', 1000) -- 1000 consecutive bytes in memory will be set to 32 -- (the ASCII code for ' ')
See Also:
Using Data Bytes, peek, poke, allocate, free, mem_copy
8.44.8 Calling Into Memory
<IP_ADDRESS> call
<built-in> procedure call(atom addr)
calls a machine language routine which was stored in memory prior.
Parameters:
- addr : an atom, the address at which to transfer execution control.
Comments:
The machine code routine must execute a RET instruction #C3 to return control to Euphoria. The routine should save and restore any registers that it uses.
You can allocate a block of memory for the routine and then poke in the bytes of machine code using allocate_code. You might allocate other blocks of memory for data and parameters that the machine code can operate on using allocate. The addresses of these blocks could be part of the machine code.
If your machine code uses the stack, use c_proc instead of call.
Example 1:
demo/callmach.ex
See Also:
Executable Memory, allocate_code, free_code, c_proc, define_c_proc
8.44.9 Allocating and Writing to memory:
<IP_ADDRESS> allocate_code
include std/machine.e namespace machine public function allocate_code(object data, memconst :valid_wordsize wordsize = 1)
allocates and copies data into executable memory.
Parameters:
- a_sequence_of_machine_code : is the machine code to be put into memory to be later called with call
- the word length : of the said code. You can specify your code as 1-byte, 2-byte or 4-byte chunks if you wish. If your machine code is byte code specify 1. The default is 1.
Returns:
An address, The function returns the address in memory of the code, that can be safely executed whether DEP is enabled or not or 0 if it fails. On the other hand, if you try to execute a code address returned by allocate with DEP enabled the program will receive a machine exception.
Comments:
Use this for the machine code you want to run in memory. The copying is done for you and when the routine returns the memory may not be readable or writeable but it is guaranteed to be executable. If you want to also write to this memory after the machine code has been copied you should use allocate_protect instead and you should read about having memory executable and writeable at the same time is a bad idea. You mustn't use free on memory returned from this function. You may instead use free_code but since you will probably need the code throughout the life of your program's process this normally is not necessary. If you want to put only data in the memory to be read and written use allocate.
See Also:
Executable Memory, allocate, free_code, allocate_protect
<IP_ADDRESS> allocate_string
include std/machine.e namespace machine public function allocate_string(sequence s, types :boolean cleanup = 0)
Allocate a C-style null-terminated string in memory
Parameters:
- s : a sequence, the string to store in RAM.
- cleanup : an integer, if non-zero, then the returned pointer will be automatically freed when its reference count drops to zero, or when passed as a parameter to delete.
Returns:
An atom, the address of the memory block where the string was stored, or 0 on failure.
Comments:
Only the 8 lowest bits of each atom in s is stored. Use allocate_wstring for storing double byte encoded strings.
There is no allocate_string_low function. However, you could easily craft one by adapting the code for allocate_string.
Since allocate_string allocates memory, you are responsible to free the block when done with it if cleanup is zero. If cleanup is non-zero, then the memory can be freed by calling delete, or when the pointer's reference count drops to zero.
Example 1:
atom title title = allocate_string("The Wizard of Oz")
See Also:
Using Strings, allocate, allocate_wstring
<IP_ADDRESS> allocate_protect
include std/machine.e namespace machine public function allocate_protect(object data, memconst :valid_wordsize wordsize = 1, valid_memory_protection_constant protection)
Allocates and copies data into memory and gives it protection using Standard Library Memory Protection Constants or Microsoft Windows Memory Protection Constants. The user may only pass in one of these constants. If you only wish to execute a sequence as machine code use allocate_code. If you only want to read and write data into memory use allocate.
See MSDN: Microsoft's Memory Protection Constants
Parameters:
- data : is the machine code to be put into memory.
- wordsize : is the size each element of data will take in memory. Are they 1-byte, 2-bytes, 4-bytes or 8-bytes long? Specify here. The default is 1.
- protection : is the particular Windows protection.
Returns:
An address, The function returns the address to the required memory or 0 if it fails. This function is guaranteed to return memory on the 8 byte boundary. It also guarantees that the memory returned with at least the protection given (but you may get more).
If you want to call allocate_protect( data, PAGE_READWRITE ), you can use allocate instead. It is more efficient and simpler.
If you want to call allocate_protect( data, PAGE_EXECUTE ), you can use allocate_code instead. It is simpler.
You must not use free on memory returned from this function, instead use free_code.
See Also:
8.44.10 Memory Disposal
<IP_ADDRESS> free
include std/machine.e namespace machine public procedure free(object addr)
frees up a previously allocated block of memory.
Parameters:
- addr, either a single atom or a sequence of atoms; these are addresses of a blocks to free.
Comments:
- Use free to return blocks of memory the during execution. This will reduce the chance of running out of memory or getting into excessive virtual memory swapping to disk.
- Do not reference a block of memory that has been freed.
- When your program terminates, all allocated memory will be returned to the system.
- addr must have been allocated previously using allocate. You cannot use it to relinquish part of a block. Instead, you have to allocate a block of the new size, copy useful contents from old block there and then free the old block.
- If the memory was allocated and automatic cleanup was specified, then do not call free directly. Instead, use delete.
- An addr of zero is simply ignored.
Example 1:
demo/callmach.ex
See Also:
Using Data Bytes, Using Data Words, Using Data Double Words, Using Strings, allocate_data, free_code
<IP_ADDRESS> free_code
include std/machine.e public procedure free_code( atom addr, integer size, valid_wordsize wordsize = 1 )
frees up allocated code memory.
Parameters:
- addr : must be an address returned by allocate_code or allocate_protect. Do not pass memory returned from allocate here!
- size : is the length of the sequence passed to alllocate_code or the size you specified when you called allocate_protect.
- wordsize: valid_wordsize default = 1
Comments:
Chances are you will not need to call this function because code allocations are typically public scope operations that you want to have available until your process exits.
See Also: Executable Memory, allocate_code, free
8.44.11 Automatic Resource Management
Euphoria objects are automatically garbage collected when they are no longer referenced anywhere. Euphoria also provides the ability to manage resources associated with euphoria objects. These resources could be open file handles, allocated memory, or other euphoria objects. There are two built-in routines for managing these external resources.
<IP_ADDRESS> delete_routine
<built-in> function delete_routine( object x, integer rid )
associates a routine for cleaning up after a Euphoria object.
Comments:
delete_routine associates a euphoria object with a routine id meant to clean up any allocated resources. It always returns an atom (double) or a sequence, depending on what was passed (integers are promoted to atoms).
The routine specified by delete_routine should be a procedure that takes a single parameter, being the object to be cleaned up after. Objects are cleaned up under one of two circumstances. The first is if it's called as a parameter to delete. After the call, the association with the delete routine is removed.
The second way for the delete routine to be called is when its reference count is reduced to 0. Before its memory is freed, the delete routine is called. A default delete will be used if the cleanup parameter to one of the allocate routines is true.
delete_routine may be called multiple times for the same object. In this case, the routines are called in reverse order compared to how they were associated.
<IP_ADDRESS> delete
<built-in> procedure delete( object x )
calls the cleanup routines associated with the object, and removes the association with those routines.
Comments:
The cleanup routines associated with the object are called in reverse order than they were added. If the object is an integer, or if no cleanup routines are associated with the object, then nothing happens.
After the cleanup routines are called, the value of the object is unchanged, though the cleanup routine will no longer be associated with the object.
8.44.12 Types and Constants
<IP_ADDRESS> std_library_address
include std/machine.e namespace machine public type std_library_address(object addr)
an address returned from allocate or allocate_protect or allocate_code or the value 0.
Returns:
An integer, The type will return 1 if the parameter, an address, was returned from one of these Machine Level functions (and has not yet been freeed)
Comments:
This type is equivalent to atom unless SAFE is defined. Only values that satisfy this type may be passed into free or free_code.
<IP_ADDRESS> valid_memory_protection_constant
include std/machine.e public type valid_memory_protection_constant(object a)
protection constants type
<IP_ADDRESS> machine_addr
include std/machine.e public type machine_addr(object a)
a 32-bit non-null machine address
<IP_ADDRESS> safe_address
include std/machine.e public function safe_address(machine_addr start, natural len, positive_int action )
action is some bitwise-or combination of the following constants: A_READ, A_WRITE and A_EXECUTE.
Returns:
When Safe Mode is turned on, this returns true iff it is ok to perform action all addresses from start to start+len-1.
When Safe Mode is not turned on, this always returns true.
Comments:
This is used mostly inside the safe library itself to check whenever you call Machine Level Access Functions or Procedures. It should only be used for debugging purposes.
<IP_ADDRESS> ADDRESS_LENGTH
include std/machine.e namespace machine public constant ADDRESS_LENGTH
The number of bytes required to hold a pointer.
<IP_ADDRESS> PAGE_SIZE
include std/machine.e namespace machine public constant PAGE_SIZE
The operating system's memory page length in bytes.
8.45 Indirect Routine Calling
8.45.1 Accessing Euphoria coded routines
<IP_ADDRESS> routine_id
<built-in> function routine_id(sequence routine_name)
returns an integer id number for a user-defined Euphoria procedure or function.
Parameters:
- routine_name : a string, the name of the procedure or function.
Returns:
An integer, known as a routine id, -1 if the named routine can't be found, else zero or more.
Errors:
routine_name should not exceed 1,024 characters.
Comments:
The id number can be passed to call_proc or call_func, to indirectly call the routine named by routine_name. This id depends on the internal process of parsing your code, not on routine_name.
The routine named routine_name must be visible (that is callable) at the place where routine_id is used to get the id number. If it is not, -1 is returned.
Indirect calls to the routine can appear earlier in the program than the definition of the routine, but the id number can only be obtained in code that comes after the definition of the routine - see example 2 below.
Once obtained, a valid routine id can be used at any place in the program to call a routine indirectly via call_proc or call_func, including at places where the routine is no longer in scope.
Some typical uses of routine_id are:
- Creating a subroutine that takes another routine as a parameter. (See Example 2 below)
- Using a sequence of routine id's to make a case (switch) statement. Using the switch statement is more efficient.
- Setting up an Object-Oriented system.
- Getting a routine id so you can pass it to call_back. (See Platform-Specific Issues)
- Getting a routine id so you can pass it to task_create. (See Multitasking in Euphoria)
- Calling a routine that is defined later in a program. This is no longer needed from v4.0 onward.
Note that C routines, callable by Euphoria, also have ids, but they cannot be used where routine ids are, because of the different type checking and other technical issues.
See Also:
define_c_proc and define_c_func
Example 1:
procedure foo() puts(1, "Hello World\n") end procedure integer foo_num foo_num = routine_id("foo") call_proc(foo_num, {}) -- same as calling foo()
Example 2:
function apply_to_all(sequence s, integer f) -- apply a function to all elements of a sequence sequence result result = {} for i = 1 to length(s) do -- we can call add1() here although it comes later in the program result = append(result, call_func(f, {s[i]})) end for return result end function function add1(atom x) return x + 1 end function -- add1() is visible here, so we can ask for its routine id ? apply_to_all({1, 2, 3}, routine_id("add1")) -- displays {2,3,4}
See Also:
call_proc, call_func, call_back, define_c_func, define_c_proc, task_create, Platform-Specific Issues, Indirect routine calling
<IP_ADDRESS> call_func
<built-in> function call_func(integer id, sequence args={})
calls the user-defined Euphoria function by routine id.
Parameters:
- id : an integer, the routine id of the function to call
- args : a sequence, the parameters to pass to the function.
Returns:
The value, the called function returns.
Errors:
If id is negative or otherwise unknown, an error occurs.
If the length of args is not the number of parameters the function takes, an error occurs.
Comments:
id must be a valid routine id returned by routine_id.
args must be a sequence of argument values of length n, where n is the number of arguments required by the called function. Defaulted parameters currently cannot be synthesized while making a indirect call.
If the function with id id does not take any arguments then args should be {}.
Example 1:
Take a look at the sample program called demo/csort.ex
See Also:
<IP_ADDRESS> call_proc
<built-in> procedure call_proc(integer id, sequence args={})
calls a user-defined Euphoria procedure by routine id.
Parameters:
- id : an integer, the routine id of the procedure to call
- args : a sequence, the parameters to pass to the function.
Errors:
If id is negative or otherwise unknown, an error occurs.
If the length of args is not the number of parameters the function takes, an error occurs.
Comments:
id must be a valid routine id returned by routine_id.
args must be a sequence of argument values of length n, where n is the number of arguments required by the called procedure. Defaulted parameters currently cannot be synthesized while making a indirect call.
If the procedure with id id does not take any arguments then args should be {}.
Example 1:
public integer foo_id procedure x() call_proc(foo_id, {1, "Hello World\n"}) end procedure procedure foo(integer a, sequence s) puts(a, s) end procedure foo_id = routine_id("foo") x()
See Also:
8.45.2 Accessing Euphoria Internals
<IP_ADDRESS> machine_func
<built-in> function machine_func(integer machine_id, object args={})
performs a machine-specific operation that returns a value.
Returns:
Depends on the called internal facility.
Comments:
This function us mainly used by the standard library files to implement machine dependent operations such as graphics and sound effects. This routine should normally be called indirectly via one of the library routines in a Euphoria include file. User programs normally do not need to call machine_func.
A direct call might cause a machine exception if done incorrectly.
See Also:
<IP_ADDRESS> machine_proc
<built-in> procedure machine_proc(integer machine_id, object args={})
perform a machine-specific operation that does not return a value.
Comments:
This procedure us mainly used by the standard library files to implement machine dependent operations such as graphics and sound effects. This routine should normally be called indirectly via one of the library routines in a Euphoria include file. User programs normally do not need to call machine_proc.
A direct call might cause a machine exception if done incorrectly.
See Also:


Syntax:
row-major-aref array index => element
(setf (row-major-aref array index) new-element)
Arguments and Values:
array---an array.
index---a valid array row-major index for the array.
element, new-element---an object.
Description:
Considers array as a vector by viewing its elements in row-major order, and returns the element of that vector which is referred to by the given index.
row-major-aref is valid for use with setf.
Examples: None.
Side Effects: None.
Affected By: None.
Exceptional Situations: None.
See Also:
Notes:
(row-major-aref array index) == (aref (make-array (array-total-size array) :displaced-to array :element-type (array-element-type array)) index) (aref array i1 i2 ...) == (row-major-aref array (array-row-major-index array i1 i2))


set vrange2 x1 x2
Specifies the range of the variable values for x-axis scaling (from x1 - x2). Reset by clear only.
clear


Interface: CC2420Ram
interface CC2420Ram
HAL abstraction for accessing theRAM of a ChipCon CC2420 radio.
- Author:
-
Jonathan Hui<EMAIL_ADDRESS>- Version:
-
$Revision: 1.2 $ $Date: 2008-06-03 04:43:03 $
Commands
command cc2420_status_t read(uint8_t offset, uint8_t *data, uint8_t length)
command cc2420_status_t write(uint8_t offset, uint8_t *data, uint8_t length)
Commands - Details
read
command cc2420_status_t read(uint8_t offset, uint8_t *data, uint8_t length)
- Parameters:
-
offset
- within the field.
-
data
- a pointer to the receive buffer.
-
length
- number of bytes to read.
- Returns:
-
status byte returned when sending the last byte
of the SPI transaction.
write
command cc2420_status_t write(uint8_t offset, uint8_t *data, uint8_t length)
- Parameters:
-
offset
- within the field.
-
data
- a pointer to the send buffer.
-
length
- number of bytes to write.
- Returns:
-
status byte returned when sending the last address byte
of the SPI transaction.


Here's the public and the private sections on this application server
Public section
Private section for role1
Private section for role2
The available users are shown below:
user1/user1 (role1)
user2/user2 (role2)
user3/user3 (role1, role2)


In this assignment, I created a mold and cast for a truncated icosahedron. You can get my .3dm
files here. Also, BIG thanks to Victor Allen for making this assignment possible!
I started creating the super mold by attempting to cut the polyhedrons in two parts. However many of the shapes downloaded from Thingiverse where meshes that didn't cut well at all. I started with a simple split using a flat surface which didn't cut the shape in the right way.
I then attempted to create a complex parting line but couldn't figure out the right way to merge the resulting shape to cut the mesh in time. Meshes are just messy.
After some web surfing, I found a Rhino plugin called RhinoPolyhedra that exports many different polyhedras that are easier to manage.
With the actual shape figured out, the rest of the super mold, including the sprues and keys, was then pretty easy to make.
Due to a mishap with making the mold (discussed later on), I optimized the super mold by thinning the walls and shortening the height to reduce print time.
Once the print is complete, I started revisiting the lecture videos to recall the instructions for using the Oomoo chemicals. Things started looking funny when the color of my mixture was white instead of purple. And right when I started pouring the mixture onto my mold, the mixture hardened into a rigid hard structure.
After consulting the packaging, turns out Amazon shipped me Smooth Cast instead of Oomoo, but stuck an Oommoo barcode sticker over it which is why it was wrongly shipped. Thanks Amazon!
As an alternative, I tried making the mold with ice, but it was very hard to remove it from the super mold without damaging the both the mold and the super mold.
After posting on Q&A Slack Channel, Victor generously offered to drop off his unused Oomoo. I coordinated with him on the drop off and jumped onto making the mold again.
I left the mixture to sit in the super mold overnight. The result was a lot better than Smooth Cast for sure!
Since I was running out of time, I decided to eyeball the plaster and water ratio and poured it slowly into the mold. It turned out that that the inner opening of my sprue was too narrow which caused a congestion when the mixture is too viscuous. This led me to think that the mold was filled when in actuality it was half-filled.
To solve this problem, I used a cutting knife to widen the inner opening. And the results were pretty great!


The Google search most correlated (r=0.96) to "madeleine cake" is "my cat loves me".
My quest is over. A cat's love must be the secret ingredient of Madeleines!
It makes total sense, Neige already helped me make jam last year.
Explore at Google Correlate but remember that correlation does not imply causation.


Studying local explanations of Bayesian Networks
We have observed that:
asia = yes
smoke = no
bronc = yes
either = no
dysp = yes
What is the probability that the patient has lung cancer?
Why is this the case?
How did you arrive at the explanation above?