notes-computer-jasper-jasperAssemblyNotes1

note that MOV can accomplish loads and stores by having one operand be a register or stack, and another be register indirect

note: if provide only CALLIF and not BNZ, then need a way to pass 'nil' to the result operand so that the return address is thrown out, so that CALLIF can simulate BNZ

Proposal: allow multiple custom opcode lookup tables in memory. This allows an interpreter to maintain computed goto versions of itself for each custom opcode table, which will execute faster. Now have a command to switch the current table (or, actually, i think this should usually be lexically scoped rather than dynamic?). In addition, have a command that says 'execute the specified command in the context of the specified opcodetable, then skip the next instruction'. This can be used for the effect of executing an instruction which is not currently assigned an opcode. Also, it seems we have an operand to spare there (one operand giving the location of the command to execute (usually the next instruction); one operand giving the desired codetable; and a third operand which would normally be a result, but is not needed now). Perhaps the codetables have a parameter which can be set here? This command does not need to be in the always-present 8-command set because it is just a way of allowing the user to have more than 16 custom commands usable without switching codetables; if the user needs that they can make it one of their custom commands.

should change MOV to CPY. A clearer name, and also it avoids confusion with 'move semantics' in HLLs (since we might actually want a MOV someday too).

special purpose registers: PC, data stack register, instruction stack register, link register? what else? how do we represent these if 'register mode' is just memory? where is the stack stored? is it the same as registers?

current guess: the stack is not the same as/mapped into low memory, it is separate, and only accessible using the stack addressing mode. This seems restrictive but it is not much since each operand always has its own addressing mode, so there's never a time you'd want to write to the stack and then read the value from low memory; the only time you'll hurt is if you write to low memory but then want to access that value using the implicit stack mode of tiny. in this case we can put registers into low memory (i'm thinking to put them above the first 32 bits, because these 32 bits are the only things accessible by 'small' instructions with 1-bit operands)

alternately you could just specify the meta stuff out-of-band by 'registering' a block of code ahead of time. This seems more efficient actually.

note: we can put the scaling parameter for an indexed,scaled addr mode in the shared operand, but then where is it in large instructions? note: we could put parameters like the comparison type for CMP in the shared operand, but then where is it in large instructions? note: maybe junk like that should all go into a register?

addr mode ideas:

would really also like: immediate with parameter register, stack indirect, indexed, memory, memory indirect

memory means that the value may be found/placed at the memory location denoted by the operand (whose interpretation differs depending on the type)

note: GET is used to index into a structure or array (e.g. GET(A, 5) = A[5] == A.__get(5), GET(A, 'b') = A.b == A.__get('b')), but is also used to apply a function (GET(f, 5) = f(5)). So to add two numbers you could do: GET(GET(ADD, 2), 3).

note: we really need ADD itself so that we can increment..

---

Proposal for opcode table: allow multiple custom opcode lookup tables in memory. This allows an interpreter to maintain computed goto versions of itself for each custom opcode table, which will execute faster. Now have a command to switch the current table (or, actually, i think this should usually be lexically scoped rather than dynamic?). In addition, have a command that says 'execute the specified command in the context of the specified opcodetable, then skip the next instruction'. This can be used for the effect of executing an instruction which is not currently assigned an opcode. Also, it seems we have an operand to spare there (one operand giving the location of the command to execute (usually the next instruction); one operand giving the desired codetable; and a third operand which would normally be a result, but is not needed now). Perhaps the codetables have a parameter which can be set here? This command does not need to be in the always-present 8-command set because it is just a way of allowing the user to have more than 16 custom commands usable without switching codetables; if the user needs that they can make it one of their custom commands.

so we need to design a good 8 opcode ISA for the fixed opcodes, and a good 4 addr modes for the fixed addr modes. note that CPY (MOV) can accomplish loads and stores by having one operand be a register or stack, and another be register indirect

special purpose registers: PC, data stack register, instruction stack register, link register, parameter register? what else? how do we represent these if 'register mode' is just memory? where is the stack stored? is it the same as registers?

current guess: the stack is not the same as/mapped into low memory, it is separate, and only accessible using the stack addressing mode. This seems restrictive but it is not much since each operand always has its own addressing mode, so there's never a time you'd want to write to the stack and then read the value from low memory; the only time you'll hurt is if you write to low memory but then want to access that value using the implicit stack mode of tiny. in this case we can put registers into low memory (i'm thinking to put them above the first 32 bits, because these 32 bits are the only things accessible by 'small' instructions with 1-bit operands)

note: if the PC is an accessible register and if you had a zillion operands, then you don't need BLE and BNE per se, you could have 'if A <= B then put C into D'. But unless it was register 0 or 1, then you couldn't do this in tiny mode, which would cripple tiny mode.

mb add a PC addressing mode? for jasper's purposes though, since we dont want to expose linear memory too much, this isn't as useful (for relative jumps, maybe, but not for locating a data storage area relative to the PC)

note: JMP is accomplished by BEQ with the branching operands both set to immediate 0. wrong: BEQ is now relative note: CALLEQ is like BEQ but first pushes the return address (the address of the next instruction) onto the call stack note: multiple stacks in place of registers

---

ok stack addressing mode is really just indirect indexed, where the table to be indexed into is located at the top of the stack, where PUSH is postincrement, and POP is predecrement, and the top of the stack pointer points at the free location above the top item of the stack. So let's replace this with an indirect immediate indexed mode. But now we need postincrement and predecrement, right? I thought addressing modes were supposed to be pure functions without side effects? Well actually the addressing mode for the 3rd, output/target operand (mb that should be first to stick with assembly language convention) can have side effects, as the point of most instructions is to mutate that item anyways. So we can have PUSH. How to fit that into our instruction encoding? Well, as noted above, the IMMEDIATE addr mode is useless on the output, so we can replace that with indirect indexed, postincrement (PUSH). We are still missing POP, but that's OK, because POPing is not pure so we don't want to use it to get inputs in addressing modes.

so in order for this to work, the stack pointer must be accessible. So we put it in a register, which is memory mapped into low memory. Also, if we want to use indirect immediate indexed for relative jumps, then the PC should also be in a register. So lets have memory location 0 be the PC, and locatinion 1 be the stack pointer. Pointers have a standard size of 16 bits. E.g. indirect index mode uses location 1 as the implicit indirect pointer (the jump-off point), and the immediate value as the relative value (the index).

But we'd also like an indirect register index mode, where you use the contents of a register, not an immediate value, as the index.

So, combining these two with the choice of indirect index or index indirect, and also the choice of whether the choice of jump-off point or the choice of index is implicit, we would seem to get 8 possibilities:

(value given is immediate or memory indirect) x (value given is for base or for index) x (indirect index or index indirect)

however, there is no distinction between base and index except for the question of indirect index or index indirect, so we really only have 4 things here.

(value given is immediate or memory indirect) x (indirect index or index indirect)

namely:

(1) i give you a value. Take the contents of the index register, and add the value to that. This is a pointer to the target. (2) i give you a value. Deref the contents of the index register, and add the value to the result. This is a pointer to the target. (3) i give you a pointer. Retrieve the value at that pointer. Take the contents of the index register, and add the value to that. This is a pointer to the target. (4) i give you a pointer. Retrieve the value at that pointer. Deref the contents of the index register, and add the value to the result. This is a pointer to the target.

now we could use a trick from another architecture (i forgot which one), where we assume that there's never any reason for an instruction to read itself, and so if modes #3 or #4 specify the PC as the pointer, instead of returning the right thing, we consider that as a code for immediate mode. In which case #3 and #4 could be used for #1 and #2 by setting the operand to zero; but then you have to have more space for the actual value somewhere.

if we make all four of these modes fundamental, then we also want an immediate mode. So there's only room for 3 custom modes then.

note that an immediate mode is not strictly needed; we can always put a lookup table of immediate values in the code, put the pointer to the table into the index register, and use mode #1. But since our operands are small we'd have to be constantly switching lookup tables, which is annoying.

note that mode #1 can be used for PC-relative pretty easily.

note that memory absolute can be given either by setting the index reg to 0 and using mode #1, or by putting the target into the index reg and using mode #1 with operand 0.

a (possibly very good) alternative to the above would be separate LEA-like instructions for each mode.

---

what is the Haskell memory representation of partially applied function?

here it is:

https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/HeapObjects#Partialapplications

--

https://en.wikipedia.org/wiki/X86-64#Architectural_features

do we need more stuff to mimic the x86-64 special registers?

--

how does haskell represent boxed types in memory? see

---

" Vacant codes are also needed by software producers for virtual instructions that can be emulated. Microsoft is using the code C4 C4 in Windows for such a purpose. This code now conflicts with the new VEX instructions, which is the reason why Intel had to disable VEX instructions in 16-bit real and virtual mode. Only two codes are reserved for software emulation. These are called UD1 (0F B9) and UD2 (0F 0B). " -- http://www.agner.org/optimize/blog/read.php?i=25#172

--

"today, we have pretty much arrived at a point where all types of data in a machine use the same size – 64-bit integers, floats, and pointers are the norm." -- http://jakob.engbloms.se/archives/2004

--

" We view belt machines as a new category of architectures, at rank equivalent to transport-triggered, or superscalar, or dataflow, or accumulator architectures " -- http://www.eetimes.com/author.asp?section_id=36&doc_id=1320257

http://ootbcomp.com/docs/belt/

i haven't watched this yet:

https://www.youtube.com/watch?v=QGw-cy0ylCc

Slides: 2013-07-11_mill_cpu_belt (.pptx)

http://millcomputing.com/blog/wp-content/uploads/2013/12/2013-07-11_mill_cpu_belt.pptx

" The belt machine model is inherently free of update hazards because all operation results go onto the belt by Single Assignment; in other words, once created they never change their value. Belt machines have no general registers and thus no rename registers that physically embody them " -- http://ootbcomp.com/docs/belt/

" By doing away with registers, the Mill avoids the very expensive renaming and managing register hazards in a conventional OOO machine. It is a potential big win in terms of power efficiency, since managing hundreds of rename registers for a user-visible set of a few dozen registers is a major painpoint in OOO processor design. The replacement is a fixed-length FIFO called the Belt (http://www.youtube.com/watch?v=QGw-cy0ylCc). Architecturally, values are read from the belt, fed into functional units, and put at the front of the belt. A bit like a stack machine, but with the ability to read from any value, not just the top of the stack. The Mill also separates between temporary values that are used to implement data flow between functional units, which are put on the Belt, and longer-term storage of values being used many times, which are put in a compiler-managed scratchpad memory. According to prior research, only some 13% of values are used more than once, the rest can easily be handled by temporary storage in a Belt. " -- http://jakob.engbloms.se/archives/2004

(in reference to http://jakob.engbloms.se/archives/2004 )

" Also, the metadata isn't like a None in Python, it's like a Maybe in Haskell! You can string them together and only throw an exception on side effects in a way that makes speculation (and vector operation) in this machine much nicer. "

--

an interesting thing about nock is thats it has no primitive binary operators which combine information about two inputs to produce an output in one step (e.g. a+b) -- everything is via state

--

--

in Liquid Republic, we have 5 branches of 'government':

can we adapt this to a 5-fold conception of jasper?

maybe:

what could the Board be? one thing obviously missing here is 'operations' If we add in 'programming language constructs' that bridges data and control flow, like the Board in LR

--

try making something 'quinary' like RDF but with more, and symmetrisized for 5

is symbolic thought binary or trinary (RDF)? maybe its quinary. todo; start with +,-,subject,verb,object and make something more symmetric. kant? quantity,quality,relation,modality?

polarity/quantity/(negation?), conditionality (from cs; e.g. if statements), (conditionality maybe or may not be the same as) role/relation, modality?, meta/paradox/escape/transcend (synthesis in thesis/antithesis/synthesis), concreteness/ identity in group theory e.g. successor/constants/projection fns in primitive recursion? and what about the object(s) to be operated on?

want 5 'places' each of which can take on 5 (kinds of?) values

bah, the idea of having each of 5 places having on of 5 values is so binary!

  note theres 5 things in. the primitive recursion defn, should pack more in there, those 5 can be the five values for one of the places

rdf provenance is like mapping onto another graph, configuration

so start with rdf, add provenance, now add one more quotation/meta/escape position?

subject/object/verb/meta/? space/time/matter/energy (or is it mass/energy?)/? configuration? knowledge/viewpoint/perspective? gravity? 0/1/-1/?/?

i guess configuration is like cs conditionality and mb role/relation?

are meta and perspective distinct? meta and configuration (annotation)?

3 = thesis/anti/synth, annotation/quotation, OR verb/role

so do we already get a whole graph structure for 3, as opposed to 'n values in n positional roles' for 2?

then what for 4,5? maybe something more like human language

hmm.. even simple positional assembly/machine language can have a 5_par scheme: opcode, 2 x (operand, addressing mode)

where does probability come in here?

--

here's one instance of 5s:

if you consider the powerset arising from elements True/False (e.g. a 'relational' logic), {}, {F}, {T}, {F,T}, we get the:

Indian catuskoti: true, false, neither true nor false, both true and false

(the Hasse diagram of First Degree Entailment logic:

   {T}
  /  \{T,F} {} \ / {F}

note that this is not identical to the set inclusion diagram in this case:

   {T,F}
  /    \{T} {F} \ / {}

)

we can add a fifth value, 'ineffable', to form a 5-valued many-valued logic.

If you then take the power set of that, you get plurivalent logic.

Plurivalent logic can be motivated by König’s paradox:

" Ordinals are numbers that extend the familiar counting numbers, 0, 1, 2, etc, beyond the finite. After we have been through all the finite numbers (of which there is, of course, an infinity), there is a next number, ω, and then a next, ω+1, and so on, forever. These ordinals share an interesting property with the counting numbers: for any set of them, if there are any members at all, there must be a least one. How far, exactly, the ordinals go is a vexed question both mathematically and philosophically. Nevertheless, one fact is beyond dispute: there are many more ordinals than can be referred to using a noun phrase in a language with a finite vocabulary, such as English. This can be shown by a perfectly rigorous mathematical proof.

Now, if there are ordinals that cannot be referred to in this way, it follows that one of them must be less than all the others, for that is true of any collection of ordinals. Consider the phrase ‘the least ordinal that cannot be referred to’. It obviously refers to the number in question. This number, then, both can and cannot be referred to. That’s our paradox. And since it cannot be referred to, one cannot say anything about it. So the facts about it are ineffable; but we can say things about it, such as that it is the least ordinal that can’t be referred to. We have said ineffable things. "

and similar problems in philosophy:

" (Kant) distinguished between two notions of noumenon, the realm beyond the senses: a positive one and a negative one. According to him, only the negative one is legitimate. We cannot talk about things of this kind; we just need to be aware of them to mark the limit of what we can talk about. Pardon? In explaining what they do, are we not talking about them? Well, yes, of course we are. "

" Gorampa was troubled enough by the situation that he attempted to distinguish between two ultimate realities: a real ultimate reality, which is ineffable, and a ‘nominal’ ultimate reality, which is what we end up talking about when we try to talk about the real ultimate. But wait a minute – the nominal ultimate is obviously effable: by definition, it is the reality that we can talk about. In that case, if we say that ultimate reality is ineffable and we are actually talking about the nominal ultimate, what we are saying is false. Thus Gorampa’s proposal refutes itself. "

-- http://aeon.co/magazine/world-views/logic-of-buddhist-philosophy/

---

note: the Hasse diagram for the 5-valued logic may be sort of 'pyramidal' if you draw the first four values as a planar diamond and the ineffable value on a different plane from the rest

note: which 5-valued value corresponds to 'neutral' in 3-valued logic? i would say 'ineffable'. So, if the first four values are drawn as a a diamond in the horizontal plane, and the ineffable value is a point on its own in the middle of the diamond but in another plane, forming a pyramid, then 3-valued logic would be a triangle with {T}, {F}, and ineffable as its points, standing vertically and cutting the pyramid diagonally.

---

start with something; add something else to trancend it; take the power set; repeat

so the sequence is:

1,2,4,5,32,33,2^33,...

so more compactly,

1,4,32,2^33, 2^(2^33+1)

as of this writing, this is not in the OEIS.

--

i guess i like this 5-valued logic as a structure for 5-valued polarity. It matches my "5 = 2^2 + 1", where the +1 represents an 'escape' or 'meta' and the 2^2 represents 2 polarities, then expanded to 2^2 to make a very symmetric object.

--

so again, some concepts that we have to work with in the search for a useful 'quinary' structure for computation:

i want the 5 elements to be somewhat symmetrical, if possible

my notion of 'polarity' seems similar to Kant's 'quality'. 'verb'/'relation'/'role' is probably like Kant's 'Relation'. I suppose quotation is like Kant's modality. So we still need Kant's 'quantity'.

Kant's quantity is, on the one hand, universal/particular/singular judgements (all x are y, some x are y, the x is y; singular can also be 'this x is y'; 'This rose is beautiful' is given as an example), and on the other, the categories of totality, plurality, unity, (mb not in that order). Unity has some correspondence with choosing a unit of measurement.

i guess this is kind of like, thinking of an individual object, vs. thinking of a bunch of objects as a plurality, vs 'set theory thinking' e.g. thinking of the set of all things satisfying some property and/or applying an operation to the set as a way of implicitly referencing the members of the set. the latter could relate to the idea of having Jasper allow one to override __apply__ to make things like implicit list variables such that operations applied to the variable are actually mapped over the list hmm.. this suggests another route to symmetry.. consider things like the symmetries of functions which are polymorphic in the type of their arguments, and arguments which via things like '__apply__' are sort of 'polymorphic' depending on the function being applied to them

hmm, if we use types, then this is coming together a little in terms of finding symmetries.. types are like quotation, but they are also like lists/sets. computation can be lifted to the type level. if computations polymorph depending on both objects and functions, then those are sort of symmetric. so types, being setlike, are a lot like kant's 'quantity', and being quotation-like, are like his 'modality'.

so we have things like:

note that correspondence or modality could each take the role of the 'meta', more symmetry.

we know that the OOP stuff also gives symmetries, can we work that in?

also, how does this compare to the 'hypergraph' model?

--

the ying/yang question of whether visible is paired with active or passive is like a symmetric square, a 4.

--

is the (traditional or modern) square of opposition related?

http://plato.stanford.edu/entries/square/

--

hypergraphs.. hmm

---

5-polarity fits with having relational variable values and operations i.e. like LIBRA

--

maybe need to have 'modifiers' as non-meta-level annotations, e.g. ways to modify nouns with adjectives and verbs with adverbs

--

human language moods:

https://en.wikipedia.org/wiki/Grammatical_mood

realis/indicative (assertion)

subjunctive (hypothetical)

conditional (true given a condition)

optative (wishes, or wishes capable of fulfillment)

imperative (direct command)

jussive and horatory (one should do this or 'let's do this')

potential (something considered likely in the opinion of the speaker)

inferential/mirative (how direct is your evidence for this statement)

interrogative (questions)

potential subjunctive (assertion that something is possible)

deliberative subjunctive (rhetorical question to self, e.g. what am i to do?)

concessive (concedes a point, e.g. "even though X, he is still a good friend")

-- https://en.wikipedia.org/wiki/Grammatical_mood , http://www.thelatinlibrary.com/101/Subjunctive1.pdf , http://people.bu.edu/tylert/Latin/independentsubjunctives.html

---

an interesting thing about nock is thats it has no primitive (0-5) binary operators which combine information about two inputs to produce an output in one step (e.g. a+b) -- everything is via state

---

also, remember that indirect addressing modes aren't strictly needed, as long as you have commands for LOAD, STO, LEA, and STOI (i think)

--

how would a biological system do it?

it probably wouldn't have equally-spaced frames, except on lower levels ('symbols'). it would have start and end delimiters.

like DNA.

the start and end delimiters can be absurdly many symbols. e.g. in a book, we have empty lines delimiting paragraphs, and many empty lines delimiting chapters, and empty pages delimiting multichapter parts. this is ok b/c they occur relatively infrequently.

so maybe we can have 'sentences.

--

views

map

fold

type attributes

--

jasper assembly: two formats: fixed width, and variable width (adjectives, start and end delimiters)

--