Author Topic: Quick question about archived programs' VAT entries  (Read 9606 times)

0 Members and 2 Guests are viewing this topic.

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Quick question about archived programs' VAT entries
« Reply #15 on: April 08, 2011, 02:55:13 pm »
Is there not a B_CALL axiom? Those routines are pretty much entirely stand-alone. If there isn't a general-purpose B_CALL axiom, I could probably throw together an axiom for these pretty quickly.
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Quick question about archived programs' VAT entries
« Reply #16 on: April 08, 2011, 03:17:17 pm »
Wowowow a b_call axiom would be freakin' cool!
EDIT: but very hard to create, I think...
EDIT2IN10SECONDS: But 1000 times easier to use than "Asm(hex)"
« Last Edit: April 08, 2011, 03:18:29 pm by aeTIos »
I'm not a nerd but I pretend:

Offline JustCause

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 810
  • Rating: +115/-5
    • View Profile
Re: Quick question about archived programs' VAT entries
« Reply #17 on: April 08, 2011, 03:21:00 pm »
Hmm. Thanks for the heads-up. I'll look into that. Legitimate assembly is not my strong point, though ;)
See you, space cowboy...

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Quick question about archived programs' VAT entries
« Reply #18 on: April 08, 2011, 03:59:28 pm »
I'm writing the axiom now. Axe Parser should really add native B_CALL support. Perhaps you could use a bitmap for telling the parser what registers to use as input and output.

By the way, what exactly does the size field measure? The following is an example of what I have. Is the size field specified correctly here?
Code: [Select]
; No .org is required because this contains no absolute pointers.
wrapChkFindSym:
; ChkFindSym(PointerToDestination, PointerToName)
; Inputs:
;  - PointerToDestination: Location to write information struct to
;    This struct has the form
;        variableStruct {byte type; byte page; word location; word VATLocation};
;  - PointerToName: Pointer to name.  The type must be the byte before the name,
;    and the name must be terminated with a 0 if less than eight characters.
; Output:
;  - Data written on success, unchanged on failure
;  - Returns 1 on failure, 0 on success
.dw wrapChkFindSymEnd-wrapChkFindSym ; Size
.db 1Fh ; Compatible with everything
.db what, ever ; Token
.db 1 ; Type (subroutine, regular)
.db 2 ; Arguments
pop bc
pop de
push bc
push de
rst 20h ; Mov9ToOP1
rst 28h
.dw _ChkFindSym
pop ix
jr c, +_
ld hl, 1
ret
_: and 1Fh
ld (ix+0), a ; I'm too lazy to deal with all the register
ld (ix+1), b ; swapping
ld (ix+2), e
ld (ix+3), d
ld (ix+4), l
ld (ix+5), h
ld hl, 0
ret
wrapChkFindSym:
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Quick question about archived programs' VAT entries
« Reply #19 on: April 08, 2011, 04:06:20 pm »
Uhh, getCalc() is a built-in wrapper for chkfindsym.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Quick question about archived programs' VAT entries
« Reply #20 on: April 08, 2011, 06:06:29 pm »
Quote
getCalc(PTR): Finds the object who's name is pointed to and returns a pointer to the start of its data, or zero if it was archived or not found.
According to this documentation, it doesn't return the variable's address if it is archived, and doesn't return the page, ever. So it would be useless if you want to read data from the archive.

I won't be here tomorrow, and probably not tonight, so here's what I have. You should be able to save this as a file and assemble it Spasm. You just need to provide tokens for it to use.
Code: [Select]
.nolist
#include "ti83plus.inc"
.list
.org 0h

.dw 0C0DEh

wrapFlashToRam:
; FlashToRam(Page, Address, Destination, Length)
; Block copies Length data from Page:Address to Destination.  Automatically
; wraps to the next page as-needed.
; Inputs:
;  - Page, Address: Source
;  - Destination: Pointer to location to copy the data
;  - Length: Amount of data to copy
.dw wrapFlashToRamEnd-wrapFlashToRam ; Size
.db 1Fh ; Compatible with everything
.db what, ever ; Token
.db 1 ; Type (subroutine, regular)
.db 4 ; Arguments
ld c, l
ld b, h
pop ix
pop de
pop hl
pop af
push ix
rst 28h
.dw _FlashToRam
ret
wrapFlashToRamEnd:


; No .org is required because this contains no absolute pointers.
wrapChkFindSym:
; ChkFindSym(PointerToDestination, PointerToName)
; Returns information about a variable.
; Inputs:
;  - PointerToDestination: Location to write information struct to
;    This struct has the form
;        variableStruct {byte type; byte page; word location; word VATLocation};
;  - PointerToName: Pointer to name.  The type must be the byte before the name,
;    and the name must be terminated with a 0 if less than eight characters.
; Output:
;  - Data written on success, unchanged on failure
;  - Returns 1 on failure, 0 on success
.dw wrapChkFindSymEnd-wrapChkFindSym ; Size
.db 1Fh ; Compatible with everything
.db what, ever ; Token
.db 1 ; Type (subroutine, regular)
.db 2 ; Arguments
; Swap return address with destination pointer
pop bc
pop de
push bc
push de
; Call
rst 20h ; Mov9ToOP1
rst 28h
.dw _ChkFindSym
; Check for failure
pop ix
jr c, +_
ld hl, 1
ret
_: ; Success!
and 1Fh
ld (ix+0), a ; I'm too lazy to deal with all the register
ld (ix+1), b ; swapping
ld (ix+2), e
ld (ix+3), d
ld (ix+4), l
ld (ix+5), h
ld hl, 0
ret
wrapChkFindSym:


wrapLoadCIndPaged:
; LoadCIndPaged(Page, Address)
; Reads a single byte from Page:Address.
; Inputs:
;  - Page: Page to read from
;  - Address: Offset to read from
; Output:
;  - Data byte
.dw wrapLoadCIndPagedEnd-wrapLoadCIndPaged ; Size
.db 1Fh ; Compatible with everything
.db ; Token
.db 1 ; Type (subroutine, regular)
.db 2 ; Arguments
pop bc
pop de
push bc
ld b, e
rst 28h
.dw _LoadCIndPaged
ld h, 0
ld l, c
ret
wrapLoadCIndPaged:


; LoadDEIndPaged(Page, Address)
; Reads a word from Page:Address.
; Inputs:
;  - Page: Page to read from
;  - Address: Offset to read from
; Output:
;  - Data word
.dw wrapLoadDEIndPagedEnd-wrapLoadDEIndPaged ; Size
.db 1Fh ; Compatible with everything
.db ; Token
.db 1 ; Type (subroutine, regular)
.db 2 ; Arguments
pop bc
pop de
push bc
ld b, e
rst 28h
.dw _LoadCIndPaged
ex de, hl
ret
wrapLoadDEIndPaged:
.dw 0
« Last Edit: April 08, 2011, 06:13:35 pm by DrDnar »
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Quick question about archived programs' VAT entries
« Reply #21 on: April 08, 2011, 06:34:46 pm »
GetCalc(PTR,FILE): Attempts to create a file of the OS variable who's name is pointed to so it can be read from archive. Returns 0 if the variable was not found or unarchived, and non-zero otherwise.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Quick question about archived programs' VAT entries
« Reply #22 on: April 09, 2011, 02:39:23 am »
I'm not sure what he needs, then, as Axe's file thing seems to allow reading data from the archive as-needed.

On another note, here's an untested B_CALL Axiom:
Code: [Select]
; B_CALL Axiom
; expr(RegisterBlock, BCallAddress)
; Calls the B_CALL. The data at RegisterBlock is loaded into the registers, and
; the register values returned by the B_CALL are written to RegisterBlock
; RegisterBlock should have the variables in the following order:
;  - If treating all as 16-bit values: AF BC DE HL
;  - If working with individual bytes: FA CB ED LH
; IMPORTANT: REGISTERBLOCK MUST POINT TO THE END OF THE REGISTER BLOCK, NOT THE
; START
; This uses self-modifing code, so cannot be used from an application.
.dw wrapBCALLEnd-wrapBCALL
.db 0Fh
.db t2ByteTok, tExpr
.db 1 ; A subroutine, because B_CALLs aren't fast and might as
.db 2 ; well save space
; I haven't done any calculations on whether this is remotely optimal.
wrapBCALL:
; Write B_CALL address
.db 7Fh ; Escape load operation
ld de, wrapSysCall
ld a, l
ld (de), a
inc de
ld a, h
ld (de), a
; Move stack stuff
pop de
pop hl
push de
; Now HL has the address of the data block
ld a, i ; Save interrupt state
push af
di ; Use SP to load values
ld (0FE70h), sp ; Replace with 9311h or any other obsecure memory area if desired
ld sp, hl
pop af
pop bc
pop de
pop hl
ld (0FE6Eh), sp
ld sp, (0FE70h)
; Perform actual B_CALL
rst 28h
wrapSysCall:
.dw 0
di ; Some B_CALLs DO mess with interrupts
; Save values using SP
ld sp, (0FE6Eh)
push hl
push de
push bc
push af
ld sp, (0FE70h)
pop af
ret po
ei
ret
wrapBCALLEnd:
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline JustCause

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 810
  • Rating: +115/-5
    • View Profile
Re: Quick question about archived programs' VAT entries
« Reply #23 on: April 11, 2011, 03:29:10 pm »
Solved. Assembling the name string from the VAT entry turned out to be much easier than I thought.

Now I've got a new issue: I know that the standard fix for the executable code limit is "put all your data at the end of the program," but if I do that I can't get to it: that is to say, I have something like this:

Code: [Select]
:[HEXDATA]->Pic1
:[MOREHEXDATA
:[EVENMOREHEXDATA

at the start of my program, and if I move it to the bottom Axe throws errors and won't let me compile (presumably because the pointer never gets initialized). What should I be doing instead?
See you, space cowboy...

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Quick question about archived programs' VAT entries
« Reply #24 on: April 11, 2011, 03:31:46 pm »
When Axe compiles, it automatically sorts out the data to the end of the program; the location of the data in the source code doesn't matter as long as you create your pointers before you reference them. Unfortunately, it also likes to mix in routines with that data. So basically, if you're over 8811, there's no way to guarantee a bug-free executable unless you use an app :( Your best bet is to try and optimize more, use appvars to hold data, or to jsut make it an app.

Offline JustCause

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 810
  • Rating: +115/-5
    • View Profile
Re: Quick question about archived programs' VAT entries
« Reply #25 on: April 12, 2011, 08:52:16 am »
Baaaaaaawwwwwwwww. Okay then, thanks for your help. Time to go burn out my archive chip!  :P
See you, space cowboy...

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: Quick question about archived programs' VAT entries
« Reply #26 on: April 12, 2011, 06:27:59 pm »
If you need to read data from the archive and don't care about speed, the OS provides several helpful routines for reading data from the archive: FlashToRam, copies an arbitrary block of data from the archive to RAM; PagedGet, used with SetupPagedPtr, lets you read and process data a byte at a time; LoadCIndPaged, reads a byte from any ROM page; and LoadDEIndPaged, reads a word from any ROM page. All of these automatically deal with wrapping, too.
DrDnar: you maybe didnt see that this was in the Axe Language section. Nice explaination, though ;)

Any Axe program that goes low-level enough has to use ASM. It just doesn't have enough commands for everything (not that that's a bad thing; I actually like how simple and consistent Axe is).

Wowowow a b_call axiom would be freakin' cool!
EDIT: but very hard to create, I think...
EDIT2IN10SECONDS: But 1000 times easier to use than "Asm(hex)"


What would a bcall Axiom do? If you mean making a command for each bcall, that would make the Axiom itself a couple megabytes large and compile in a few hours O.O
« Last Edit: April 12, 2011, 06:29:29 pm by Deep Thought »




Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Quick question about archived programs' VAT entries
« Reply #27 on: April 15, 2011, 11:49:00 pm »
No, I meant an Axiom that executes any B_CALL, loading and saving the registers for you, too. Axe itself might implement something like
B_CALL(var8->reg, var16r->reg16, Routine address, reg8->var8, reg16->var16r) ; calls the Routine, loading variables to registers before and copying registers to variables after.
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC