Omnimaga
Calculator Community => TI Calculators => ASM => Topic started by: Munchor on June 01, 2011, 02:58:35 am
-
I'd like to know something for my first ASM program.
How to get MAX and Current Archive in ASM Code?
Is there a pointer to it, or a B_CALL that returns it?
Thanks
-
Getting the amount of free flash is complicated. Available flash is a different story. You can just use the model. An 83+ has 32 pages, an 83+ SE has 64, an 84+ has 128, and an 84+ SE has 256. I may be wrong on the later models, and I didn't account for the space the OS takes up.
-
I think the 83+ has 32 pages, 84+ has 64, and both the 83+SE and 84+SE have 128. The garbage collector assumes a page is empty when it starts with $FF but I don't know how to get the amount of free flash down to the byte.
-
Available flash is a different story.
So?
Also, do I have to get Model in ASM and then for each model have a MAX Archive?
-
After a little bit of research and coding, this is what I have come up with! Calling GetTotalArc will return a pointer to a string containing the total amount of user archive. Calling GetFreeArc will return a pointer to a string containing the amount of free archive.
All the routines put together are 76 bytes, which isn't too bad I guess. If anyone knows of any super top secret OS calls that can make this smaller/easier, feel free to suggest them. And before you suggest it, I purposely avoided Disp32 because it doesn't work on all OS versions. Also if I used any calls that don't work on every OS version, feel free to point that out as well.
GetTotalArc:
;——————————————————————————————————————————————;
;—> Returns the total amount of user archive as a 7-character decimal string
;INPUTS: none
;OUTPUTS: hl=pointer to string (OP3)
;DESTROYS: af bc de ix
;——————————————————————————————————————————————;
B_CALL($80BA) ;GetHWVer
add a,a
add a,a
ld d,0
ld e,a
ld hl,GetTotalArc_HWValues
add hl,de
jr ConvArc
GetTotalArc_HWValues:
.db (10*$4000)>>24&$FF,(10*$4000)>>16&$FF,(10*$4000)>>8&$FF,(10*$4000)&$FF
.db (94*$4000)>>24&$FF,(94*$4000)>>16&$FF,(94*$4000)>>8&$FF,(94*$4000)&$FF
.db (30*$4000)>>24&$FF,(30*$4000)>>16&$FF,(30*$4000)>>8&$FF,(30*$4000)&$FF
.db (94*$4000)>>24&$FF,(94*$4000)>>16&$FF,(94*$4000)>>8&$FF,(94*$4000)&$FF
GetFreeArc:
;——————————————————————————————————————————————;
;—> Returns the amount of free archive as a 7-character decimal string
;INPUTS: none
;OUTPUTS: hl=pointer to string (OP3)
;DESTROYS: af bc de ix
;——————————————————————————————————————————————;
B_CALL($5014) ;ArcChk
ex de,hl
inc hl
ConvArc:
;——————————————————————————————————————————————;
;—> Converts a 32-bit integer into a 7-character decimal string
;INPUTS: hl=pointer to 32-bit integer (big-endian)
;OUTPUTS: hl=pointer to string (OP3)
;DESTROYS: af bc de ix
;——————————————————————————————————————————————;
rst 20h
ld hl,OP3+7
ld de,10
ld (hl),d
ld b,7
ConvArc_Loop1:
push bc
push hl
B_CALL($80B1) ;Div32By16
pop hl
pop bc
ld a,(OP2+3)
add a,'0'
dec hl
ld (hl),a
djnz ConvArc_Loop1
ld d,h
ld e,l
ld bc,6<<8+'0'
ConvArc_Loop2:
ld a,(de)
cp c
ret nz
ld a,' '
ld (de),a
inc de
djnz ConvArc_Loop2
ret
-
Runer112, that was really helpful, thanks.
SirCmpwn told me about a BCall that returns Free Archive, _ChkFreeArc.
However, yours is more precise as it returns the same free archive listed in MEMORY, and the BCall is not so accurate.
-
Runer112, that was really helpful, thanks.
SirCmpwn told me about a BCall that returns Free Archive, _ChkFreeArc.
However, yours is more precise as it returns the same free archive listed in MEMORY, and the BCall is not so accurate.
Well, runer actually uses a bcall too.
B_CALL($5014) ;ArcChk
And since this bcall isn't officially or unofficially named, and doesn't even appear in wikiTi or TI's routines, there's a good chance that SirCmpwn and Runer are actually talking about the same bcall ;)