Author Topic: Custom parser commands? :O  (Read 6296 times)

0 Members and 1 Guest are viewing this topic.

Offline ZippyDee

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +83/-8
  • Why not zoidberg?
    • View Profile
Custom parser commands? :O
« on: March 24, 2011, 05:14:46 am »
Being new to ASM, I still have a lot of questions. Here's my most recent one:

I understand that it's possible to add new commands to the command parser and also (I think) to modify the way other commands are interpreted, but I have no idea HOW this is done. Can anyone explain?

Thanks again,
-Zippy Dee
There's something about Tuesday...


Pushpins 'n' stuff...


SirCmpwn

  • Guest
Re: Custom parser commands? :O
« Reply #1 on: March 24, 2011, 08:59:15 am »
Perhaps you mean macros?  The method changes from assembler to assembler, so you'll have to tell us which one you're using.
Macros are a special sort of command that changes text.  For example, you could make a macro where "thisisamacro" would be equivalent to "ret".  Certain types of macros have other features, such as parameters.  One such example is bcall.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Custom parser commands? :O
« Reply #2 on: March 24, 2011, 09:13:34 am »
Or do you mean on the calc where you change what things like dim( or real( do?

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Custom parser commands? :O
« Reply #3 on: March 24, 2011, 09:33:07 am »
It sounds like you're talking about modifying what the interpreter itself does. Modifying the interpreter can involve some heavy OS modification, which is pretty much the last thing you want to be doing if you're new to ASM. However, since I know you'll be curious, here's kind of a general overview of what would be necessary:

First, to parse a token, the interpreter steps through an array containing all of the tokens and does some fancy parsing in order to transform those commands into something it can understand. For example, something like 3x+3 is transformed into another format that's easier for the computer to parse. For simplicity (and because I have no idea how TI calcs parse expressions  :P), we'll skip that part and just go to single token parsing like Dim(L1). In order to parse this, the OS loads the arguments into the proper memory locations. It then looks up the Dim( token in a big table and sees that it's supposed to perform an operation on the arguments and finds the addresses of the proper system call(s). It then calls those functions and when they're done, waits for the next token to come along.

If you can't tell, in order to change the tokens, you'd either have to do a parser hook which intercepts the token and parses it by itself or modify the OS itself. The first is possible, but still difficult. The latter is well, difficult to judge. Let me just put it this way: In general, the most complex and massive program a programmer can write is an OS. Modifying an OS isn't easy to do properly without some serious knowledge of the OS in question. Also, it should be apparent that modifying a system call may have impacts beyond what was intended if the call is used elsewhere.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

SirCmpwn

  • Guest
Re: Custom parser commands? :O
« Reply #4 on: March 24, 2011, 09:52:04 am »
There's no need to do an OS patch, you could just use a parser hook, if that's what he means.

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Custom parser commands? :O
« Reply #5 on: March 24, 2011, 05:39:31 pm »
Well, you'll notice that I did mention those ;)

However, OS patches don't permanently reassign the OS commands. The parser hooks are uninstalled after every RAM clear.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline ZippyDee

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +83/-8
  • Why not zoidberg?
    • View Profile
Re: Custom parser commands? :O
« Reply #6 on: March 25, 2011, 03:05:43 am »
Ok, so changing the way it interprets seems fairly improbable for me to EVER do, even once/if I get good at ASM. But changing the string for a token sounds like it would be easier.
There's something about Tuesday...


Pushpins 'n' stuff...


Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Custom parser commands? :O
« Reply #7 on: March 25, 2011, 09:25:53 am »
It is possible, just take Omnicalc, for example. Omnicalc changes the parser by using the parser hook.
http://wikiti.brandonw.net/index.php?title=83Plus:Hooks:9BAC
^^ is about the parser hook
I'm not a nerd but I pretend:

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Custom parser commands? :O
« Reply #8 on: March 25, 2011, 11:01:24 am »
Ok, so changing the way it interprets seems fairly improbable for me to EVER do, even once/if I get good at ASM. But changing the string for a token sounds like it would be easier.

That's a different hook, called the Token Hook :)




Offline ZippyDee

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +83/-8
  • Why not zoidberg?
    • View Profile
Re: Custom parser commands? :O
« Reply #9 on: March 26, 2011, 05:03:43 am »
Ah, okay. Well I think I'd like to learn how to do that once I understand all of this a little more.

Thanks for all your help, everyone.
There's something about Tuesday...


Pushpins 'n' stuff...


SirCmpwn

  • Guest
Re: Custom parser commands? :O
« Reply #10 on: March 26, 2011, 11:29:03 am »
The token hook isn't too difficult, but beware with the parser hook - it is very difficult to use, and I've never personally had success with it.

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Custom parser commands? :O
« Reply #11 on: March 26, 2011, 11:47:02 am »
Using a parser hook is the same as asking for a headache without any aspirin.  Many of us are more than happy to help you out, but I recommend staying away from the parser hook until you become more fluent in ASM.

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: Custom parser commands? :O
« Reply #12 on: March 26, 2011, 11:57:44 am »
Using a parser hook is the same as asking for a headache without any aspirin.  Many of us are more than happy to help you out, but I recommend staying away from the parser hook until you become more fluent in ASM.
Even if your name starts with B. Some hooks are just nightmarish.