hspl

sentenceInterpretYa: ; HSPL Human Speakable Programming Language

changelog.txt

October 21, 2011, hexDay 15, hexWeek 2,1, ya
 14:42 hmmm, perhaps I should get the ya function working, of writing to file
       likely should add them to a new book, leave the root book for root functions.
       it would allow for making more proper functions, that modify the sentence by adding a so argument.
       then a look up would be able to find the result, rather than having to go through the hassel of resolving.
 17:07 I’ve been thinking about lysh, lambda sysh, or three-clause sysh, since most of the functions only have 2 arguments..
       ….. I guess it’s been done before,  but it would be fairly easy to write an interpreter for such a thing,
       also the whole three clause thing has been used for intermediary representation and bytecode.
       that was kind of the idea with the older version of sysh… though datastruc made it rather confusing…
       okay so lets figure this out…. how will it run?    I write something and read stuff….
       basically modifying a file,  and it’s sentences,  variables can be stored as sentence arguments…
       name su  value bo variable be ya
       danger being that we’re making a full-fledged programming language, in assembly, rather than through our virtual machine…
      so how do we do the virtual machine stuff huh? like maybe we should make a bytecode interpreter kinda thing…
      but we can simply optimize by having the equivalent spacing option,  though I guess that might not work so easily.
      sysh was never meant to be the full fledged HSPL, it’s just we’ve gotten so good at assembly coding it’s becoming that way…
      maybe we’ll be able to finish this, even though it’s all sentence based now…
      currently I have the do functions working with sentenceInterpret,
      perhaps I need to make a sentenceWrite or sentencePut for ya
 19:37 so what’s the algorithm for the sentencePut function?
       input be context(book), and sentence,
       algorithm is sentenceSpace bookAppend
 20:20 wrote sentenceInterpretYa
October 20, 2011, hexDay 14, hexWekk 2,1, ya
 09:54 so what now? seems like I might get turing complete with a few more additions,
       need mov, cmp, jmp and some conditional jmps
changelog.txt quote

interpert.asm

sentenceInterpretYa:
       ;input be context(book), and sentence,
       ;algorithm is sentenceSpace, textAppend or textInsert
           pushr [sentenceInterpretLength]
           pushr [sentenceInterpretAddress]
        pushr bookletSize
        pushr [book]
        call textInsert
        movr eax,[sentenceInterpretAddress]
        movr ebx,[sentenceInterpretLength]
        jmp sentenceInterpretYes

interpert.asm sourcecode

HSPL Human Speakable Programming Language: caseInterpret, typeInterpret, codeGet

changelog.txt

October 16, 2011, hexDay 10, hexWeek 2,1 ya
 06:30 helo
 06:56 perhaps append should return a string
       meh, maybe a little later, after this is debugged to functioning properly
09:29 fixed codeGet, issue was improper arguments from sentenceInterpret
 10:04 todo debug caseInterpret
 12:00 caseInterpret debugged,
 13:41 working on debugging typeInterpret
 14:00-30 nap 30-15:00 cooking
15:52  fixed typeInterpret!
 15:55 fixed glyphsatofNumbers
 15:53 now should probably integrate caseInterpret in sentenceInterpret
 16:16 looking at B-tree’s,  seems it would be good to do as earlier planned,
     having extra space for each sentence and word, to make modifications easier.
     each sentence could be saved in a 256 glyph region (sentenceSize), some may of course overflow,
                              in such case can move next sentence to make room.
    in my magic-spell-book usually I don’t modify things, I just keep going, and add new sentences, as I update them.
    or sometimes when I go back, I write additions in the margins,  so that is like the “extra space”.
 16:43 issue with integrate caseInterpret, is that have to store the sentence, convert the cases, and only then run the verb
     obviously it can be achieved with recursion.  the questions abound, such as, will a sentence be enough room? perhaps I should do my modifications in a book.  currently the types convert to smaller things, but what if they reference a large quote,  I guess then it would simply resolve to the quote address, ahh, so then a sentenceSize should suffice,  since most of the cases will becomes smaller, merely addresses followed by lengths, though there could be some issue with recognizing addresses which have 0’s or synonyms of blanks.
 17:01 earlier versions of sysh, had everything arranged by addresses and lengths, there were no words or blanks, perhaps I could follow a similar example. 
 17:05 alternatively could let the command do the conversions..
 17:09 meh, for now, can blog caseInterpret, typeInterpret and codeGet
October 15, 2011 hexDay 9, hexWeek 2,1 ya
 15:30 todo write typePush and typeInterpret
 15:34 perhaps shall rename my .asm files to .nasm files for proper syntax highlighting
       hmmm .nasm extension doesn’t turn on syntax highlighting but,
       simply moving syntax/nasm.vim to syntax/asm.vim does work.
 15:50 wrote typePush
 16:23 working on typeInterpret algorithm
 15:39, gotta split sentenceInterpret, to make codeGet subfunction.
 18:30 finished writing typeInterpret, todo codeGet
 19:49 wrote codeGet
 19:56 it’s gonna be time to debug soon
 22:39 finished compile-time debugging
 23:57 going to sleep
October 14, 2011 hexDay 8, hexWeek 2,1 ya
 01:00 revising cases
 01:30 debugging cases
 02:06 aCaseGet works
 02:17 aLastCaseGet works
02:18 case revision complete, though casePush order could still be optimized, it depends on usage
 10:24 sentenceInterpret functioning properly
 10:25 maybe should make a case spreadsheet
 10:29 though soon should implement mov and such functions,  most interesting might be jmp
       also todo research how to use parallel processors so can do low-level implementation
 10:58 okay, have bunch of resources for doing parallel,  will leave it for later
       right now, more important to implement the simple functions
       like types,  to support registers, and numbers
 10:59 sleepy, nap time.
 14:50 back
 18:20 so samta tells me about adjectives, and that articles can be adjectives.
 18:21 I’m still somewhat confused about my being a case, as it seems more of an adjective to me.
       hmmm it seems any noun modifier is an adjective, so we have to be a bit more specific.
       other than case there are a variety of other grammatical categories, so how shall we deal with them?
       should we simply start with types, and then work from there?
       btw, my case is fine, it can be used to store meta-data, like optimization metrics, and personal relation.
       lets examine the various grammatical categories:
         animacy (chakra density), aspect(temporal flow), Clusivity (inclusive/exclusive),
         Definiteness (a, the), Degree of comparison (compare), Evidentiality (citation),
         Focus, Gender, Mirativity, Modality Mood Noun class Number Person Polarity Tense Topic Transitivity Voice
      grammatical functions: object, subject, adjunct (comment, optional-case), complement (necessary-case).
 19:37 okay anyways, I gotta do one thing at a time here,  lets get types to work
       that would imply hmmm what’s the algorithm for type?
       in caseInterpret,  drop case word, get last word, interpret last word,
            if last word is a type then process rest of case contents by sending to appropriate function and return result
            else return case contents
 22:08 wrote caseInterpret, todo typeInterpret, typePush
 23:00 working on nu type
 23:30 wrote nu type
 23:39 clearing args su subtraction with esp bo faster maybe
changelog.txt quote

interpret.asm quote

section .bss
  resr caseInterpretResultAddress,byteBase
;section .data
  resr caseInterpretResultLength,byteBase
section .text
caseInterpret: ; interperts case, such as type, and outputs result
      ; case address and case length bo input be
      ; word address and word length bo output be
      ; algorithm be
      ; in caseInterpret,  drop case word, get last word, interpret last word,
      ;      if last word is a type then process rest of case contents by sending to appropriate function and return result
      ;      else return case contents
      ; in caseInterpret,  drop case word,
      ;     to drop, have to get last word, then use it’s start address as end address
      mov eax,[esp+byteBase*1]
      mov ecx,[esp+byteBase*2]
      pushr ecx
      pushr eax
      call aLastWordGet
      pop eax
      pop ecx
      ; if no then exit
      cmp eax,no
      jz caseInterpretNo
      ; set length to end at word’s start
       ; string length su end bo word start at set be
      ;eax; word’s start
      ;[esp+byteBase*2]; string length
      movr ebx,[esp+byteBase*1]; string start
      subr eax,ebx; word start - string start = length
      movr [esp+byteBase*2],eax; length set
      ; set variables
      movr eax,[esp+byteBase*1]
      movr ecx,[esp+byteBase*2]
      movr [caseInterpretResultAddress],eax
      movr [caseInterpretResultLength],ecx
 ;     ; get last word, interpret last word,
 ;     pushr ecx
 ;     pushr eax
 ;     call aLastWordGet
 ;     pop eax
 ;     pop ecx
 ;     ; if is type then interpret
      push ecx
      push eax
      call typeInterpret
      pop eax
      pop ecx
      cmp eax,no
      jnz caseInterpretEnd
      ;      else return case contents
      jmp caseInterpretYes
;caseInterpretCallTypeInterpret:
;        pushr [caseInterpretResultLength]
;        pushr [caseInterpretResultAddress]; length
;    call typeInterpret
;    pop eax
;    pop ecx
;    jmp caseInterpretEnd
caseInterpretNo:
      movr ecx,no
      movr eax,no
      jmp caseInterpretEnd
caseInterpretYes:
      movr ecx,[caseInterpretResultLength]
      movr eax,[caseInterpretResultAddress]; length
      jmp caseInterpretEnd
caseInterpretEnd:
      pop edx; ret
      pop ebx; arg 1
      pop ebx; arg 2
      pushr ecx; length
      pushr eax; address
      pushr edx
      ret
     
interpret.asm sourcecode

type.asm

section .data
  datr typesQuantity,1
   ; types list,  number nu,  quote quo te,
section .text
typePush: ;pushes the available types onto the stack
   pop edx
   pushr nu_length
   pushr nu_name
   push edx
   ret
section .bss
  resr typeInterpretResultAddress,byteBase
  resr typeInterpretResultLength,byteBase
section .text
typeInterpret: ; interpret be types bo
   ; input be type address and type length bo
   ; output be word address and word length bo
   ; algorithm be quo
   ;     get be the typeWord ya from infer be type-contents ya
   ;     codeGet be typeWord su contents bo return so do te bo ya

   ;     get be the typeWord bo aLastWordGet with ya
   movr eax,[esp+byteBase*1]; type address
   movr ecx,[esp+byteBase*2]; type length
   push ecx
   push eax
   call aLastWordGet
   pop eax
   pop ecx
   ; if none then exit
   cmp eax,no
   jz typeInterpretNo
      ;      if last word is a type then process rest of case contents by sending to appropriate function and return result
      ;        first type to implement is numbers nu,  then can implement registers re
      ;        hmmm, perhaps can simply do a word lookup, or could use for higher level types, 
      ;         nu can be hardcoded as it is required for basic lookup, 
      ;         concievably we could simply not convert to letters,
      ;         but that would make it unreadable, and thereby unspeakable.
      ;        is there a generic way we could determine it is a type?
      ;             perhaps we could do an arLastWordGet instead, with a typePush to generify arguments
      call typePush
      pushr [typesQuantity]
      push ecx
      push eax
      call arLastWordGet
      pop eax
      pop ecx
   ; if is type then interpret
    cmp eax,0
    jz typeInterpretNo
   ;     su infer be type-contents bo ya
   ; result address su set be type start bo
   movr ebx,[esp+byteBase*1]; type start bo
   movr [typeInterpretResultAddress],ebx ; result address su set be
   ; su result length bo set be contents end address minus start address with be
   movr edx,eax; copy be end address bo
   subr edx,ebx; end address minus start address
   movr [typeInterpretResultLength],edx; result length bo set be
   ;
   ;     codeGet be typeWord bo book su return so do te bo ya
   pushr ecx ; type length
   pushr eax ; type address
   ;pushr bookletSize
   ;pushr [book]
   call codeGet
   pop eax ; code address, address
   pop ecx ; code address, length
   ; if none then default exit
   cmp eax,no
   jz typeInterpretYes
   ; make sure is byteBase long
   pushr [typeInterpretResultLength];[esp+byteBase*2]; contents length
   pushr [typeInterpretResultAddress];[esp+byteBase*1]; contents address
   call [eax]
   pop eax
   pop ecx
   ; return so
   jmp typeInterpretEnd
typeInterpretNo:
   movr eax,no
   movr ecx,no
   jmp typeInterpretEnd
typeInterpretYes:
   movr eax,[typeInterpretResultAddress]
   movr ecx,[typeInterpretResultLength]
   jmp typeInterpretEnd
typeInterpretEnd:
   pop edx; ret
   pop ebx; arg 1
   pop ebx; arg 2
   push ecx; length
   push eax; address
   push edx
   ret
type.asm sourcecode

book.asm

section .data
  datr typesQuantity,1
   ; types list,  number nu,  quote quo te,
section .text
typePush: ;pushes the available types onto the stack
   pop edx
   pushr nu_length
   pushr nu_name
   push edx
   ret
section .bss
  resr typeInterpretResultAddress,byteBase
  resr typeInterpretResultLength,byteBase
section .text
typeInterpret: ; interpret be types bo
   ; input be type address and type length bo
   ; output be word address and word length bo
   ; algorithm be quo
   ;     get be the typeWord ya from infer be type-contents ya
   ;     codeGet be typeWord su contents bo return so do te bo ya

   ;     get be the typeWord bo aLastWordGet with ya
   movr eax,[esp+byteBase*1]; type address
   movr ecx,[esp+byteBase*2]; type length
   push ecx
   push eax
   call aLastWordGet
   pop eax
   pop ecx
   ; if none then exit
   cmp eax,no
   jz typeInterpretNo
      ;      if last word is a type then process rest of case contents by sending to appropriate function and return result
      ;        first type to implement is numbers nu,  then can implement registers re
      ;        hmmm, perhaps can simply do a word lookup, or could use for higher level types, 
      ;         nu can be hardcoded as it is required for basic lookup, 
      ;         concievably we could simply not convert to letters,
      ;         but that would make it unreadable, and thereby unspeakable.
      ;        is there a generic way we could determine it is a type?
      ;             perhaps we could do an arLastWordGet instead, with a typePush to generify arguments
      call typePush
      pushr [typesQuantity]
      push ecx
      push eax
      call arLastWordGet
      pop eax
      pop ecx
   ; if is type then interpret
    cmp eax,0
    jz typeInterpretNo
   ;     su infer be type-contents bo ya
   ; result address su set be type start bo
   movr ebx,[esp+byteBase*1]; type start bo
   movr [typeInterpretResultAddress],ebx ; result address su set be
   ; su result length bo set be contents end address minus start address with be
   movr edx,eax; copy be end address bo
   subr edx,ebx; end address minus start address
   movr [typeInterpretResultLength],edx; result length bo set be
   ;
   ;     codeGet be typeWord bo book su return so do te bo ya
   pushr ecx ; type length
   pushr eax ; type address
   ;pushr bookletSize
   ;pushr [book]
   call codeGet
   pop eax ; code address, address
   pop ecx ; code address, length
   ; if none then default exit
   cmp eax,no
   jz typeInterpretYes
   ; make sure is byteBase long
   pushr [typeInterpretResultLength];[esp+byteBase*2]; contents length
   pushr [typeInterpretResultAddress];[esp+byteBase*1]; contents address
   call [eax]
   pop eax
   pop ecx
   ; return so
   jmp typeInterpretEnd
typeInterpretNo:
   movr eax,no
   movr ecx,no
   jmp typeInterpretEnd
typeInterpretYes:
   movr eax,[typeInterpretResultAddress]
   movr ecx,[typeInterpretResultLength]
   jmp typeInterpretEnd
typeInterpretEnd:
   pop edx; ret
   pop ebx; arg 1
   pop ebx; arg 2
   push ecx; length
   push eax; address
   push edx
   ret

book.asm sourcecode

HSPL Human Speakable Programming Language: sub, mul, div

changelog.txt

October 19, 2011, hexDay 13, hexWeek 2,1 ya
 18:22 at least implement syshSub today
18:28 syshSub implemented, and fixed, from case - bo case
 18:30 implement mul,  by case * bo case
20:41 mul implemented and fixed.
 21:29 wrote div
21:33 fixed div

changelog.txt

commands.asm

;codePut syshSub,“sub”,3,0,[book]
section .bss
   resr syshSubSentenceAddress,byteBase
   resr syshSubSentenceLength,byteBase
   resr syshSubBoNumber,wordSize
   resr syshSubBoLength,byteBase
   resr syshSubFromNumber,wordSize
   resr syshSubFromLength,byteBase
section .text
codePut syshSub,“sub”,3,0,[book]
    ; input be sentenceAddress eax, sentenceLength ebx.
    ;    requires cases bo, and to
    ; output be string with result in so case.
    ; algorithm be
    ; requried variables be sentence, cases for
    ; get interpert be ‘bo’ and 'to’ cases bo
    ; do the subition,  return the function

    ; requried variables be sentence, cases for
    ; get interpert be 'bo’ and 'to’ cases bo
    movr [syshSubSentenceAddress],eax
    movr [syshSubSentenceLength],ebx
    push bo_length
    push bo_name
    push ebx
    push eax
    call caseGet
    pop eax
    pop ebx
    cmp eax,no;if no then exit
    jz syshSubNo
    push ebx
    push eax
    call caseInterpret
    pop eax
    pop ebx
    movr eax,[eax]; get actual number
    movr [syshSubBoNumber],eax
    movr [syshSubBoLength],ebx
    movr eax,[syshSubSentenceAddress]
    movr ebx,[syshSubSentenceLength]
    push from_length
    push from_name
    push ebx
    push eax
    call caseGet
    pop eax
    pop ebx
    cmp eax,no;if no then exit
    jz syshSubNo
    push ebx
    push eax
    call caseInterpret
    pop eax
    pop ebx
    ; do the subition,  return the function
    movr eax,[eax]
    movr ecx,[syshSubBoNumber]
    sub eax,ecx
    movr [syshSubFromNumber],eax
    movr eax,syshSubFromNumber ; output must be address of number, rather than number itself
    ; return the converted number
    ;mov eax,eax
    ;mov ebx,ebx
    ret
syshSubNo:
     mov eax,no
        mov ebx,no
    ret
section .bss
   resr syshMulSentenceAddress,byteBase
   resr syshMulSentenceLength,byteBase
   resr syshMulBoNumber,wordSize
   resr syshMulBoLength,byteBase
   resr syshMulByNumber,wordSize
   resr syshMulByLength,byteBase
section .text
codePut syshMul,“mul”,3,0,[book]
    ; input be sentenceAddress eax, sentenceLength ebx.
    ;    requires cases bo, and to
    ; output be string with result in so case.
    ; algorithm be
    ; requried variables be sentence, cases for
    ; get interpert be 'bo’ and 'to’ cases bo
    ; do the mulition,  return the function

    ; requried variables be sentence, cases for
    ; get interpert be 'bo’ and 'to’ cases bo
    movr [syshMulSentenceAddress],eax
    movr [syshMulSentenceLength],ebx
    push bo_length
    push bo_name
    push ebx
    push eax
    call caseGet
    pop eax
    pop ebx
    cmp eax,no;if no then exit
    jz syshMulNo
    push ebx
    push eax
    call caseInterpret
    pop eax
    pop ebx
    movr eax,[eax]; get actual number
    movr [syshMulBoNumber],eax
    movr [syshMulBoLength],ebx
    movr eax,[syshMulSentenceAddress]
    movr ebx,[syshMulSentenceLength]
    push by_length
    push by_name
    push ebx
    push eax
    call caseGet
    pop eax
    pop ebx
    cmp eax,no;if no then exit
    jz syshMulNo
    push ebx
    push eax
    call caseInterpret
    pop eax
    pop ebx
    ; do the mulition,  return the function
    movr eax,[eax]
    movr ecx,[syshMulBoNumber]
    ; clear edx (overflow register)
    xor edx,edx
    ; multiply
    mul ecx
    movr [syshMulByNumber],eax
    movr eax,syshMulByNumber ; output must be address of number, rather than number itself
    ; return the converted number
    ;mov eax,eax
    ;mov ebx,ebx
    ret
syshMulNo:
     mov eax,no
        mov ebx,no
    ret
section .bss
   resr syshDivSentenceAddress,byteBase
   resr syshDivSentenceLength,byteBase
   resr syshDivBoNumber,wordSize
   resr syshDivBoLength,byteBase
   resr syshDivByNumber,wordSize
   resr syshDivByLength,byteBase
section .text
codePut syshDiv,“div”,3,0,[book]
    ; input be sentenceAddress eax, sentenceLength ebx.
    ;    requires cases bo, and to
    ; output be string with result in so case.
    ; algorithm be
    ; requried variables be sentence, cases for
    ; get interpert be 'bo’ and 'to’ cases bo
    ; do the divition,  return the function

    ; requried variables be sentence, cases for
    ; get interpert be 'bo’ and 'to’ cases bo
    movr [syshDivSentenceAddress],eax
    movr [syshDivSentenceLength],ebx
    push by_length
    push by_name
    push ebx
    push eax
    call caseGet
    pop eax
    pop ebx
    cmp eax,no;if no then exit
    jz syshDivNo
    push ebx
    push eax
    call caseInterpret
    pop eax
    pop ebx
    movr eax,[eax]; get actual number
    movr [syshDivByNumber],eax
    movr [syshDivByLength],ebx
    movr eax,[syshDivSentenceAddress]
    movr ebx,[syshDivSentenceLength]
    push bo_length
    push bo_name
    push ebx
    push eax
    call caseGet
    pop eax
    pop ebx
    cmp eax,no;if no then exit
    jz syshDivNo
    push ebx
    push eax
    call caseInterpret
    pop eax
    pop ebx
    ; do the divition,  return the function
    movr eax,[eax]
    movr ecx,[syshDivByNumber]
    ; clear edx (overflow register)
    xor edx,edx
    ; divide
    div ecx
    movr [syshDivBoNumber],eax
    movr eax,syshDivBoNumber ; output must be address of number, rather than number itself
    ; return the converted number
    ;mov eax,eax
    ;mov ebx,ebx
    ret
syshDivNo:
     mov eax,no
        mov ebx,no
    ret

commands.asm

HSPL human speakable programming language: codePut, textInsert, arWordGet, aCaseGet, aSentenceGet

HSPL human speakable programming language:

changelog.txt quote

September 14, hexDay 10, hexWeek 0,1
————————————
 07:30 started working on code
08:30 debugged append, wordAppend, codePut
  todo get codePut to write to book, currently does areaSay
 10:00 returned from returning heaven book to library
10:30 wrote and tested textInsert, seems to work
  okay so what now? getting function, return variable, do code
   arWordGet (ar) caseGet (wa) sentenceGet (ku)   codeDo (do)
 10:40-11:30 nap 11:40 making soup
 13:00 debugged numbersToGlyphs, now gives proper length
 13:12 might need to rewrite glyphsToNumbers to support infinite length numbers
 13:27 higher priority is arWordGet so lets test it with interpreter
 16:30 debugging arWordGet,
 17:00 added Length Result to arWordGet
17:40 debugged arWordGet
 17:50 what now? placeGet, sentenceGet, codeDo
    can’t use numbers till after code can be done anyhow
   though yes, it would be convenient to see the code-address in hexadecimal,                                                   perhaps with li function to convert it to code afterwards, yet again, requiring code doing to be operational first…
   anyhow writing fresh functions is more fun than debugging or rewriting :-).
 16:00 making burgers 16:30 went to get tomatoes 19:00 eating
 19:15 back, debugging aCaseGet
 19:52 debugged aCaseWordGet
 20:00 hmmm, to get first case, might have to rewrite arWordGet                                                                  to do full search on each aWordGet, rather than using wordGet,
20:22 debugged aCaseGet, added nest and nester to arWordGet
 20:30 debugging aSentenceGet
21:02 debugged aSentenceGet
 21:20 writing caseGet, lastWord
22:01 wrote notBlankReverseGet, blankReverseGet, lastWordGet

changelog.txt

datastruc.asm sourcecode

%macro codePut 5 ; label,name,nameLength,meta,index followed by code
; call %1_init ; to create entry after using macro
section .rodata
     %1_length  equ  %3
;section .bss
;    resr %1_sentence,sentenceSize; since this is only used once can used shared version,  
section .data ;
    datr %1_flags,%4
    datr %1_name,%2
section .text
%1_init:
    ; make sentence string, record to root book
    ;  name la su codeAddress rei bo code be ya
    ;      perhaps some stringBuilder functions would be good
    ;       such as,  append, taking stringAddress, length, returning newStart
    ;       could also make an wordAdd, which surrounds addition with spaces
    push %1_length
    push %1_name
    push sentence
    call wordAppend ; adds name
    pop eax
    push su_length ; is subject
    push su_name
    push eax
    call wordAppend ; indicates subject added
    pop eax
    ;movr [h1],eax; temporarily store eax
    ; convert number to glyphs, then add
    
    push byteBase
    push %1_code
    ;call numbersToGlyphs
    ;pop ebx; glyphAddress
    ;pop ecx; glyphLength
    ;movr eax,[h1]; retrieve eax
    ;push  ecx;
    ;push ebx
    push eax
    call wordAppend ; adds code; perhaps we should convert it to glyphs first
    pop eax
    push bo_length
    push bo_name
    push eax
    call wordAppend; indicates object added
    pop eax
    push code_length
    push code_name
    push eax
    call wordAppend ; add code
    pop eax
    push be_length
    push be_name
    push eax
    call wordAppend; add be
    pop eax
    ; finalize sentene with ya
    push ya_length
    push ya_name
    push eax
    call wordAppend
    pop eax;
    ; figure out length,
    ; find clear space in book of sufficient length
    movr ecx,eax
    movr ebx,sentence
    subr ecx,ebx ; length of sentence added
    ; add to book
    ; textInsert input, bookAddress, textAddress, textLength
    pushr ecx; length
    pushr ebx; textAddress
    pushr %5 ; bookAddress
    call textInsert
    
    ;push %1_flags; I’ve never used flags anyhow
    ;movr eax,%5; %5 is address of book to add it to
    ;pushr [eax+listLatestPlace] ; prevLink
    ;pushr 5 ; number of Entry sections
    ;push eax ; TODO make entries modular, arg  listAddress numberOfEntries pushed onto stack
    ;call addEntry
    ret
%1_code:
%endmacro

datastruc.asm

book.asm sourcecode


textInsert: ; inserts text to book, to first available cleanSpace in main-section
    ; input: bookAddress, textAddress, textLength
    ; output: none for now, perhaps later, success or otherwise
    ; cleanSpace input startAddress length amount, output spaceAddress
    movr ecx,[esp+byteBase*3]; textLength
    movr ebx,[esp+byteBase*1]; bookAddress
    ; later can skip cover of book
    pushr ecx ; amount
    pushr bookSize ; length
    pushr ebx; startAddress
    call cleanSpace
    pop eax; spaceAddress
    ; copyMove input, length, destination, source
    movr ecx,[esp+byteBase*3]; textLength
    movr ebx,[esp+byteBase*2]; textAddress
    pushr ebx; source
    pushr eax; destination
    pushr ecx; length
    call copyMove
    ; return
    pop edx; ret
    pop ebx; arg 1
    pop ebx; arg 2
    pop ebx; arg 3
    push edx; ret
    ret

book.asm

gramParser.asm sourcecode

section .bss
   resr arWordGetCounter,byteBase
   resr arWordGetAddress,byteBase
   resr arWordGetLength,byteBase
   resr arWordGetAddressResult,byteBase
   resr arWordGetLengthResult,byteBase
section .text
arWordGet:; Array Word Get: returns word encountered and length
     ; input,  stringAddress 1, stringLength 2, arrayLength 3,  
     ;          firstWordAddress 4, firstWordLength 5, NthWordAddress even, NthWordLength odd
     ; output, wordStartAddress, wordLength
     ; algorithm, can loop through array using countTillWord,
     jmp arWordGetNest
arWordGetNest:
  ; hmmm, might have to rewrite it so that it does a full search, for each aWordGet till no more words, or found
      ; algorithm,  arWordGet, then jmp aWordGetMid,  if returns 0, then jump back here, till no more
     ; clear counter
     xor ecx,ecx; start of Array
     movr [arWordGetCounter],ecx
     ; do aWordGet, store wordAddress and length
     movr ecx,[esp+byteBase*2];length
     movr eax,[esp+byteBase*1];address
     pushr ecx
     pushr eax
     call aWordGet
     popr eax; address
     popr ecx; length
     ; if length 0 then exit
     cmp ecx,no
     jz arWordGetNo
     movr [arWordGetLength],ecx
     movr [arWordGetAddress],eax    
     jmp arWordGetMid
arWordGetNester:
     ; increment address, and reduce length appropriately
     ; increment address
     movr ebx,[arWordGetAddress]
     addr ebx,[arWordGetLength]; get endOfWordAddress, shall be newAddres
     movr [esp+byteBase*1],ebx
     ; reduce length
     movr eax,[esp+byteBase*1]; stringAddress
     addr eax,[esp+byteBase*2]; stringLength; gets endOfStringAddress
     subr eax,ebx; new length, is endOfStringAddress - endOfWordAddress
     movr [esp+byteBase*2],eax
     jmp arWordGetNest
arWordGetMid:
     ; check has not yet reached end of array
     movr edx,[esp+byteBase*3]; arrayLength
     movr ecx,[arWordGetCounter]; current entry
     cmpr ecx,edx; compare counters
     jz arWordGetNester; if equal then go back to nest
     movr edx,[esp+byteBase*(4+ecx*2+1)]; wordLength
     movr ecx,[esp+byteBase*(4+ecx*2)]; wordAddress
     movr ebx,[arWordGetLength]; stringLength
     movr eax,[arWordGetAddress]; stringAddress
     movr [arWordGetLengthResult],edx ; save a copy of wordLength
     ; call wordGet
     pushr edx; wordLength
     pushr ecx ; wordAddress
     pushr ebx ; stringLength
     pushr eax ;stringAddress
     call wordGet
     pop eax; result
     ; if positive then exit successfully
     cmpr eax,no
     jnz arWordGetYes
     ; if negative then increment counter and recurse
     movr ecx,[arWordGetCounter]; current entry
     addr ecx,1
     movr [arWordGetCounter],ecx; current entry
     jmp arWordGetMid
arWordGetNo:
     ; a bit more complex to clear args,  
     ; number of array entries times 2 plus the 3 initial
     movr eax,[esp+byteBase*3]; arrayLength
     ; multiply by 2
     xor edx,edx; clear edx
     movr ebx,2
     mul ebx
     ; eax is number of args to clear
     addr eax,3; adding the final 3
     pushr eax
     call clearArgs
     pop edx ; ret
     pushr no ; no length
     pushr no ; no address
     push edx
     ret
arWordGetYes:
     ; save result
     movr [arWordGetAddressResult],eax
     ; a bit more complex to clear args,  
     ; number of array entries times 2 plus the 3 initial
     movr eax,[esp+byteBase*3]; arrayLength
     ; multiply
     xor edx,edx; clear edx
     movr ebx,2
     mul ebx
     ; eax is result
     addr eax,3; adding the final 3
     pushr eax
     call clearArgs
     pop edx;ret
     pushr [arWordGetLengthResult];
     pushr [arWordGetAddressResult]
     push edx;ret
     ret
; if we return with length including the word,  
;  a lastWord function could easily find the case, or sentence type
aCaseGet: ; gets next case word
   ; input stringStart, stringLength
   ; output caseLength
   ; algorithm call arWordGet
   movr ebx,[esp+byteBase*2]; stringLength
   movr eax,[esp+byteBase*1]; stringAddress
   pushr so_length
   pushr so_name
   pushr that_length
   pushr that_name
   pushr which_length
   pushr which_name
   pushr with_length
   pushr with_name
   pushr from_length
   pushr from_name
   pushr yo_length
   pushr yo_name
   pushr on_length
   pushr on_name
   pushr at_length
   pushr at_name
   pushr by_length
   pushr by_name
   pushr in_length
   pushr in_name
   pushr for_length
   pushr for_name
   pushr to_length
   pushr to_name
   pushr of_length
   pushr of_name
   pushr bo_length
   pushr bo_name
   pushr su_length
   pushr su_name
   pushr be_length
   pushr be_name
   pushr casesQuantity
   pushr ebx
   pushr eax
   call arWordGet
   popr eax; address
   pop  ecx; length
   ; return result
   jmp aCaseGetEnd
aCaseGetEnd:
   ; address can technically be original start address
   ; length can be distance from original startAddress to end of caseWord
   addr ecx,eax; makes ecx address at end of case word
   popr edx; ret
   popr eax; stringAddress
   subr ecx,eax ; makes ecx length till end of case word
   popr ebx; stringLength
   pushr ecx; length
   pushr edx; ret
   ret

caseGet: ; gets a particular case, from within first sentence and within length
   ; input,  stringAddress, stringLength, caseName, caseLength
   ; output,  caseStartAddress, caseLength, including caseName
   ; algorithm,  
   ;  caseStartAddress variable, caseLength variable,
   ;   aSentenceGet, to find end of sentence if within length, set as end
   ;   aCaseGet, if proper case return, else move-up startAddress and recurse.
   movr eax,[esp+byteBase*1]; stringAddress
   movr ecx,[esp+byteBase*2]; stringLength
   pushr ecx
   pushr eax
   call aSentenceGet
   pop ecx; length
   movr [esp+byteBase*2],ecx; update length
   xor ecx,ecx;
   jmp caseGetMid
caseGetMid:
   movr ecx,[esp+byteBase*2]; length
   movr eax,[esp+byteBase*1]; address
   pushr ecx
   pushr eax
   call aCaseGet
   pop ecx; length
   ; if no case, then exit
   cmp ecx,0
   jz caseGetNo
   ; if case, check if proper case, get lastWord, and stringCompare
   movr eax,[esp+byteBase*1]; start address
   movr ebx,[esp+byteBase*2]; length
   pushr ebx
   pushr eax
   call lastWordGet
   pop eax; lastWordAddress
   pop ebx; lastWordLength
caseGetNo:
   popr edx; ret
   pop eax; address
   pop ebx; length
   pushr ecx; length to end of case
   pushr eax; startAddress of case

gramParser.asm

sentence.asm sourcecode

aSentenceGet: ; gets next sentenceWord
   ; input stringStart, stringLength
   ; output sentenceStart, sentenceLength
   movr ecx,[esp+byteBase*2]; stringLength
   movr eax,[esp+byteBase*1]; stringAddress
   pushr ku_length
   pushr ku_name
   pushr do_length
   pushr do_name
   pushr ya_length
   pushr ya_name
   pushr sentenceTypesQuantity
   pushr ecx
   pushr eax
   call arWordGet
   popr eax; address
   pop ecx; length
   ; return result
   jmp aCaseGetEnd

sentence.asm

HSPL: sysh, lettersToNumbers and mathPower debugged

I implemented them as the function “li” which translates the trueSpace from letters to numbers

commands.asm

codeEntry li,“li”,2,0,[definitions]; 15; math, infinite
    ; li function, translates true literal into numeric representation.
    ;  etymology “li” was used to indicate numbers in lojban, end-quote was bo libo
                ; pa re ci vo mu xu ze bi so pau rau cau vau mua
     ; obviously later these commands will be part of the written text, for now (register-version) they aren’t recorded.
    ; where is the true space? the space where things are kept before they organized
    ; use lettersToNumbers
    pushr byteBase ; length
    pushr trueSpace; startAddress
    call lettersToNumbers
    popr eax; result
    movr [trueSpace],eax ; update trueSpace
    next


commands.asm sourcecode

math.asm


lettersToNumbers:; convert letters to number
    ; input strAddress length; right handed or left handed? assume right-handed? later can make arg
   ; takes letters, converts them to numbers of the appropriate base,
   ;   and adds them up with corresponding multiplication for significance of place.
   ;movr ebx,[numericBase]
   ; assuming right-handed numbers i.e. thousand = 0001
   xor ecx,ecx; place-counter
   movr [h1],ecx;  clear result holder
   movr [h2],ecx; something holder
   movr [h3],ecx; counter holder
   jmp lettersToNumbersMid
lettersToNumbersMid:
   ; check counter is less or equal to length
   movr ecx,[h3]; counter
   movr edx,[esp+byteBase*2];length
   cmpr ecx,edx
   jz lettersToNumbersEnd; if length reached, end
   ; get first letter, change to number, multiply by place, add to result
   movr edx,[esp+byteBase*1];startAddress
   addr edx,ecx; add counter to address
   xor ebx,ebx; clear ebx
   mov bl,[edx]; got first byte of number
   ; beneficial to have alphabet list, that corresponds to value of number,
     ; then can search through hexadecimal also, same function
   ; if we have a string charAt function, would be beneficial, it’s similar to stringContains
   ;  or can do it based on numeric ASCII to avoid calling external functions, meh hardcoding ~
   ; charAt
   ;pushr numAlphabetLen ; length
   ;pushr numAlphabet; string
   ;pushr ebx; char
   ;call charAt
   ;popr ebx; result, if negative then parseError with optional recovery, else process and add result to counter
   ;cmp ebx,0
   ;jl notLettersToNumbers
   ; hmmm, but if we use numberString, we don’t take into account alternative representations of numbers, such as lowercase.
   ; we could of course use multiple numberStrings, though perhaps can do faster with some math skills
   ;   if the number is between 0x30 and 0x39 then 0 through 9,  if 0x41 to 0x46 A to F, if 0x61 to 0x66 then a to f
   ; bl is current letter, so compare it to the various integer parts
   cmp bl,0x30
   jl lettersNulltoNumbers
   cmp bl,0x40
   jl letters0to9Numbers
   cmp bl,0x47
   jl lettersAtoFNumbers
   cmp bl,0x67
   jl lettersatofNumbers
   ;else continue, or throw error/exception
   jmp lettersNulltoNumbers
lettersNulltoNumbers:
   ; skip unrecognized numbers; todo can log exception, perhaps throuhg stderr
   jmp lettersToNumbersContinue
letters0to9Numbers:
  subr ebx,0x30 ; set to proper base
  jmp yesLettersToNumbers

lettersAtoFNumbers:
  subr ebx,0x41-9 ; set to proper base
  jmp yesLettersToNumbers

lettersatofNumbers:
  subr ebx,0x61-9 ; set to proper base
  jmp yesLettersToNumbers

yesLettersToNumbers:
  movr [h2],ebx; store ebx for call
  ; multiply by place, need to get exponent of base, so make power function
  pushr ecx
  pushr [numericBase]
  call powerMath
  popr eax
  movr ebx,[h2]
  mul ebx ; multiply number by it’s place to make it at it’s place,
           ; could also use the shr function, though only with hexadecimal
  movr ecx,[h1]; result-holder copied to ecx
  addr eax,ecx ; add  to current number
  movr [h1],eax ; store result
  jmp lettersToNumbersContinue ; continue

lettersToNumbersContinue:
   ; increment counter and recurse
   xor ecx,ecx;clear ecx
   movr ecx,[h3] ;retrieve counter
   addr ecx,1 ; increment counter
   movr [h3],ecx ; store counter
   jmp lettersToNumbersMid
  
lettersToNumbersEnd:
    popr edx; ret
    popr ebx; arg 1
    popr ebx; arg 2
    pushr [h1]; result; potentially could return address of number and length, so infinite size numbers
    pushr edx; ret
    ret
   
powerMath: ; multiplies base times itself, “power” times.
   ; input:  base,  power
   ; output: result
   movr eax,[esp+byteBase];base
   movr ecx,[esp+byteBase*2];power
   movr ebx,eax; copy base
   jmp powerMathMid
powerMathMid:
   cmp ecx,1          ; if power counter
   jz powerMathDone     ; is 1 then exit
   jl nullPowerMath     ; is 0 then set to 1 and exit
   mul ebx         ; else multiply base times self,
   subr ecx,1           ;   and decrement counter
   jmp powerMathMid       ; then recurse

nullPowerMath:
   movr eax,1; set to 1
   jmp powerMathDone; exit

powerMathDone:
   popr edx; ret
   popr ebx ; arg 1
   popr ebx ; arg 2
   pushr eax; result
   pushr edx ; ret
   ret

math.asm sourcecode

HSPL: sysh, lettersToNumbers

Logan wrote lettersToNumbers code,

usually my stuff works excellent,

and maximize efficiency with rapid prototyping, and stream-lining.

stream-lining in terms of doing coding all in one go, doing debugging all in one go, faster than going back and forth, changing mind-states.

so I leave the debugging till implementation.

command I’ll be implementing to use it, is the “to”,“from”,“at” grammatical-cases, so can read/write/modify at to or from various locations.

math.asm

lettersToNumbersContinue:
   ; increment counter and recurse
   xor ecx,ecx;clear ecx
   movr ecx,[h3] ;retrieve counter
   addr ecx,1 ; increment counter
   movr [h3],ecx ; store counter
   jmp lettersToNumbersMid

lettersToNumbersEnd:
    popr edx; ret
    popr ebx; arg 1
    popr ebx; arg 2
    pushr [h1]; result; potentially could return address of number and length, so infinite size numbers
    pushr edx; ret
    ret


math.asm sourcecode