Author Topic: question for searching  (Read 12114 times)

0 Members and 1 Guest are viewing this topic.

Offline alex99

  • LV3 Member (Next: 100)
  • ***
  • Posts: 80
  • Rating: +9/-5
    • View Profile
    • Alexstudious
question for searching
« on: April 20, 2013, 01:11:56 pm »
2. is it possible to see progs, i mean that i put (for example) a "--" at the beginning of a prog and the axe prog see it and use it??? i know that it is possible in asm but in axe???mean something like .xy to show that it is an axe prog or :DCS for a picture

can you help me ???
 
VISIT:

www.atomsoftware.jimdo.com

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: question for searching
« Reply #1 on: April 20, 2013, 02:07:22 pm »
I believe you want to search for all programs on the calculator that start with some certain pattern? Once you've located a program, checking for a certain pattern should be fairly straightforward: just compare the first few bytes read from the program to values/ranges you want them to be in. But the key to being able to do what you want is being able to search through the VAT, a list of all variables on the calculator, to find programs. Probably the easiest way to do this is with MemKit, an Axiom included in the Tools folder in the Axe release. How to include the Axiom and use the individual commands is explained fairly well in the readme, so I'll get right to generally how you want to use MemKit. You generally want to loop through all items in the VAT in a style like this:

Code: [Select]
Load()         .Start at beginning of VAT
While 1        .Start loop
If dim()=5     .If this VAT entry is a program
.The next line is a little hacky and will not work in versions lower than 1.2.1
.This manually sets up Y₀ to be used to access this variable
(dim()ʳʳ→{°Y₀+2}??dim()ʳ,dim()ʳ-16384)→{°Y₀}ʳ
.Here you perform whatever checks to see if the variable fits your pattern and act accordingly
End
End!If Next()  .Continue loop if there are more VAT entries to process
« Last Edit: April 20, 2013, 02:07:34 pm by Runer112 »

Offline alex99

  • LV3 Member (Next: 100)
  • ***
  • Posts: 80
  • Rating: +9/-5
    • View Profile
    • Alexstudious
Re: question for searching
« Reply #2 on: April 24, 2013, 02:39:48 pm »
"Here you perform whatever checks to see if the variable fits your pattern and act accordingly"
sorry but actually where to locate the letters between dim()or there where the question mark is???
VISIT:

www.atomsoftware.jimdo.com

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: question for searching
« Reply #3 on: April 24, 2013, 10:47:33 pm »
Are you asking what those tokens are? The ʳ and ° are both found in the ANGLE menu, accessible from 2nd + APPS. And you probably knew these already, but just to be complete, dim( is accessible from 2nd + STAT + right, and Y₀ is accessible from VARS + right + 1/enter. Everything else on that line can be found directly on the keypad.

But what does the comment from the line below it have to do with it? That comment is a placeholder saying that you want to replace it with the actual logic of testing if programs match your pattern and processing them accordingly.
« Last Edit: April 24, 2013, 10:49:06 pm by Runer112 »

Offline alex99

  • LV3 Member (Next: 100)
  • ***
  • Posts: 80
  • Rating: +9/-5
    • View Profile
    • Alexstudious
Re: question for searching
« Reply #4 on: April 25, 2013, 12:54:42 am »
no where to write my mark like fore axeparser .xy i want to makethis mark++as++ but where i have to locate it  in this code above???
VISIT:

www.atomsoftware.jimdo.com

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: question for searching
« Reply #5 on: April 25, 2013, 01:03:56 am »
In the code I gave, you'd replace that comment with your code to check for the pattern you want. How you check for the pattern is up to you, and depends on the pattern you want to match. For whatever pattern you're checking, you'll probably end up using multiple instances {n+Y₀} to read the nth byte (0-indexed) of the program and compare the value to the expected byte/range.
« Last Edit: April 25, 2013, 01:04:41 am by Runer112 »

Offline alex99

  • LV3 Member (Next: 100)
  • ***
  • Posts: 80
  • Rating: +9/-5
    • View Profile
    • Alexstudious
Re: question for searching
« Reply #6 on: April 29, 2013, 04:38:43 am »
first another question i hope you are runner 112 from cametech
i said to to you the copy problem:
Code: [Select]
:"A"→Str1
:length(Str1)→L
:If GetCalc("prgmASDF",L)→A
:Copy(Str1,A,L)
:Else
:Disp "Creation error"
:End
and that it is only copiing the d from disp...
now i made another code
Code: [Select]
:getcalc("str1"-->A
:length(A)→L
:If GetCalc("prgmASDF",L)→B
:Copy(A,B,L)
:Else
:Disp "Creation error"
:End
now is all fine it is copiing all from str1 to a prog
but there is one bug it is copiing something like pton( or dec at the end so there is one command that i don´t want to have! :mad: how can i fix this bug????
« Last Edit: April 29, 2013, 04:41:25 am by alex99 »
VISIT:

www.atomsoftware.jimdo.com

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Offline TheMachine02

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 452
  • Rating: +105/-0
  • me = EF99+F41A
    • View Profile
Re: question for searching
« Reply #7 on: April 29, 2013, 10:09:53 am »
you can simply do :

Code: [Select]
getcalc("str1"-->A
length(A)→L
If GetCalc("prgmASDF",L-1)→B
Copy(A,B,L-1)
Else
Disp "Creation error"
End

the bug came from the last byte, that is not a part of the string

EDIT : oops, I corrupt data with copy(A,B,L)
« Last Edit: April 29, 2013, 11:55:22 am by TheMachine02 »
AXE/asm programmer - unleash the power of z80 //C++//C

epic 3D things http://www.ntu.edu.sg/home/ehchua/programming/opengl/CG_BasicsTheory.html

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: question for searching
« Reply #8 on: April 29, 2013, 02:00:25 pm »
The first issue I see is the omitted closing parenthesis after GetCalc( on the first line. Unlike in TI-BASIC, a store operation in Axe does not automatically close all unmatched parentheses before it, so that code would really be storing the pointer to the raw string data "Str1" rather than the result of calling GetCalc("Str1"). Close your parenthesis in Axe!

The other issue is that the length() command is for finding the length of null-terminated strings of data. But OS variables that can have a variable size, including OS strings, don't use null termination to mark their size, but instead have the size stored as a 2-byte header immediately before the data. So if you have a pointer to an OS program, appvar, picture, equation, or string in the variable A, then the size of the data (not including the 2-byte size header) can be accessed with {A-2}r.'

With those two changes applied to your code, hopefully this should work:

Code: [Select]
:GetCalc("Str1")→A
:{A-2}ʳ→L
:If GetCalc("prgmASDF",L)→B
:Copy(A,B,L)
:Else
:Disp "Creation error"
:End

Offline alex99

  • LV3 Member (Next: 100)
  • ***
  • Posts: 80
  • Rating: +9/-5
    • View Profile
    • Alexstudious
Re: question for searching
« Reply #9 on: April 30, 2013, 04:52:15 am »
the method from themachine02 is working but thanks for both answears

another question :
i want build something like xlib and i dont know how to make that it then runs when a hook is includet.i mean xlib alweas answear when there is a real( .is it possible to make something like that in axe. whenyes how ???
VISIT:

www.atomsoftware.jimdo.com

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: question for searching
« Reply #10 on: April 30, 2013, 11:33:47 am »
Hooks cannot be made with pure Axe. You'd need to mix in a fair amount of assembly for the hook management.

Offline Joshuasm32

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 142
  • Rating: +19/-7
    • View Profile
    • Network
Re: question for searching
« Reply #11 on: April 30, 2013, 06:16:22 pm »
Axe technically is assembly.  I would add stuff like that to a new addition of axe, though, so that Axe will remain pure.
« Last Edit: April 30, 2013, 06:39:26 pm by codebender »
My name is Josh and I a developer at Moonzean. I enjoy Radiohead, web development, Java, and cryptograms.
Spoiler For No Surprises, by Radiohead:
A heart that's full up like a landfill
A job that slowly kills you
Bruises that won't heal

You look so tired unhappy
Bring down the government
They don't, they don't speak for us

I'll take a quiet life
A handshake of carbon monoxide

And no alarms and no surprises
No alarms and no surprises
No alarms and no surprises
Silent, silent

This is my final fit
My final bellyache

With no alarms and no surprises
No alarms and no surprises
No alarms and no surprises please

Such a pretty house
And such a pretty garden

No alarms and no surprises
No alarms and no surprises
No alarms and no surprises please

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: question for searching
« Reply #12 on: April 30, 2013, 06:32:28 pm »
Axe is not assembly, just like C is not assembly. And Axe doesn't natively support things like hooks for a couple of reasons. Hooks don't really interface with languages other than assembly well, because it's common for inputs/outputs to be in specific CPU registers, or even flags. And different hooks have different inputs/outputs, so it's not really easy to handle them all. Also, because most hooks deal with core OS functionalities, it's common that the hook needs to use OS constant definitions, which are readily available to assembly programmers, but not Axe programmers. And this one isn't a deal-breaker, but generally hooks should be fast; a slow hook can really bog down a calculator. Assembly code can be made to be far faster than Axe, and I don't want to encourage the production of bulky and slow hooks.


tl;dr Hooks are best left to assembly, in my opinion.
« Last Edit: April 30, 2013, 07:08:56 pm by Runer112 »

Offline Joshuasm32

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 142
  • Rating: +19/-7
    • View Profile
    • Network
Re: question for searching
« Reply #13 on: April 30, 2013, 06:38:54 pm »
Right.  Axe compiles into ASM.
My name is Josh and I a developer at Moonzean. I enjoy Radiohead, web development, Java, and cryptograms.
Spoiler For No Surprises, by Radiohead:
A heart that's full up like a landfill
A job that slowly kills you
Bruises that won't heal

You look so tired unhappy
Bring down the government
They don't, they don't speak for us

I'll take a quiet life
A handshake of carbon monoxide

And no alarms and no surprises
No alarms and no surprises
No alarms and no surprises
Silent, silent

This is my final fit
My final bellyache

With no alarms and no surprises
No alarms and no surprises
No alarms and no surprises please

Such a pretty house
And such a pretty garden

No alarms and no surprises
No alarms and no surprises
No alarms and no surprises please

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: question for searching
« Reply #14 on: May 02, 2013, 02:02:42 am »
It compiles into bulky, slower and extremely unoptimized machine code (although far less than it used to), because it's an high-level language, it would be nearly impossible to write an Axe compiler that achieves speed and size as fast as pure ASM. It's not as bad as with C, though, because Axe was designed with Z80 processors in mind, unlike C. Don't get me started on BASIC to ASM converters.


I bet that a good Axe programmer would be able to achieve hooks with no ASM, but it would be a major PITA to code and the resulting code would be massive and considerably slower. Some languages are just not done for lower level stuff (for example, good luck erasing the OS certificate from a pure BASIC program). There is also the issue of trying to keep Axe compiler as small as possible. People don't want a 10 pages APP on their calc just to compile Axe code into machine language.

(On a side note, Runer112 is the one in charge of Axe Parser development and given his history of crazy optimizations to any ASM sources he finds, he knows very well what he's talking about.)
« Last Edit: May 02, 2013, 02:08:16 am by DJ Omnimaga »