Omnimaga
Calculator Community => TI Calculators => ASM => Topic started by: Munchor on May 28, 2011, 07:31:32 am
-
I finished my first useful ASM program:
; Program Name: Memory Checker
; Author: David Gomes
; Version: 0.1
; Written for Doors CS 7.0 and higher
.nolist
#include "ti83plus.inc"
#include "dcs7.inc"
.list
.org userMem-2
.db $BB,$6D
Init:
B_CALL (_ClrLCDFull)
set textWrite,(IY + sGrFlags)
set fracDrawLFont,(IY + fontFlags)
ld a,1
ld (penCol), a
ld a,1
ld (penRow), a
ld hl,Title
B_CALL (_VPutS)
ld h,0
ld l,9
ld d,95
ld e,9
ld a,1
call fastline
res fracDrawLFont,(IY + fontFlags)
ld a,10
ld (penRow),a
ld a,1
ld (penCol),a
B_CALL (_memchk)
call VDispHL
ld a,17
ld (penRow),a
ld a,1
ld (penCol),a
ld hl,OutOf
B_CALL (_VPutS)
ld a,24
ld (penRow),a
ld a,1
ld (penCol),a
ld de,24756
ld h,d
ld l,e
call VDispHL
call iFastCopy
B_CALL (_GetKey)
ret
Title:
.db "Memory Checker",0
OutOf:
.db "out of",0
It only works in DoorsCS7 as it was written for it. It displays the free RAM and the total RAM. So if your free RAM is 11000 it says:
11000
out of
24576
I will be adding more stuff to it as I learn more ASM. What do you think?
-
Ouch. You forgot something very important! The header!
-
Indeed, if you are going to use DCS routines, you should probably throw a DCS header on it. The header ensures that shells that don't support DCS funcions won't try to run it. If they do, it will obviously crash (or do something really interesting.)
Also, this line of code made me laugh:
ld de,24756
ld h,d
ld l,e
call VDispHL
I'll let you figure out what's wrong ;) Think of it as an exercise.
-
This:
ld a,1
ld (penCol), a
ld a,1
ld (penRow), a
could be
ld a,1
ld (penCol), a
ld (penRow), a
because the ld command does not affect registers (except the ones that are loaded to lol)
-
Which could be further optimized to:
ld hl, 1*256+1 ;penRow * 256 + penCol
ld (penCol), hl
-
Yeah, thats true. You can use that in Axe too. ( Text(Y*256+X) \ Text "STRINGHERE" )
-
I made some updates, what do you think?
; Program Name: Memory Checker
; Author: David Gomes
; Version: 0.2
; Written for Doors CS 7.0 and higher
.nolist
#include "ti83plus.inc"
#include "dcs7.inc"
.list
.org progstart
.db $BB,$6D
Init:
B_CALL (_ClrLCDFull)
set textWrite,(IY + sGrFlags)
set fracDrawLFont,(IY + fontFlags)
ld a,1
ld (penCol), a
ld (penRow), a
ld hl,Title
B_CALL (_VPutS)
ld h,0
ld l,9
ld d,95
ld e,9
ld a,1
call fastline
res fracDrawLFont,(IY + fontFlags)
ld a,10
ld (penRow),a
ld a,1
ld (penCol),a
B_CALL (_memchk)
call VDispHL
ld a,17
ld (penRow),a
ld a,1
ld (penCol),a
ld hl,OutOf
B_CALL (_VPutS)
ld a,24
ld (penRow),a
ld a,1
ld (penCol),a
ld hl,24756
call VDispHL
call iFastCopy
B_CALL (_GetKey)
res textWrite,(IY + sGrFlags)
ret
Title:
.db "Memory Checker",0
OutOf:
.db "out of",0
Added an "about" by the way:
; Program Name: Memory Checker
; Author: David Gomes
; Version: 0.2
; Written for Doors CS 7.0 and higher
.nolist
#include "ti83plus.inc"
#include "dcs7.inc"
.list
.org progstart
.db $BB,$6D
Init:
B_CALL (_ClrLCDFull)
set textWrite,(IY + sGrFlags)
set fracDrawLFont,(IY + fontFlags)
ld a,1
ld (penCol), a
ld (penRow), a
ld hl,Title
B_CALL (_VPutS)
ld h,0
ld l,9
ld d,95
ld e,9
ld a,1
call fastline
res fracDrawLFont,(IY + fontFlags)
ld a,10
ld (penRow),a
ld a,1
ld (penCol),a
B_CALL (_memchk)
call VDispHL
ld a,17
ld (penRow),a
ld a,1
ld (penCol),a
ld hl,OutOf
B_CALL (_VPutS)
ld a,24
ld (penRow),a
ld a,1
ld (penCol),a
ld hl,24756
call VDispHL
ld a,57
ld (penRow),a
ld a,1
ld (penCol),a
ld hl,MadeBy
B_CALL (_VPutS)
call iFastCopy
B_CALL (_GetKey)
res textWrite,(IY + sGrFlags)
ret
Title:
.db "Memory Checker",0
OutOf:
.db "out of",0
MadeBy:
.db "by David Gomes",0
-
Looks good, the last thing you should do to bring it up to optimized is change things like
;4 bytes
ld d, 95
ld e, 5
;to
;3 bytes
ld de, 95*256+5
And also
;10 bytes
ld a, 17
ld (penRow), a
ld a, 1
ld (penCol), a
;to
;6 bytes
ld hl, 17*256+1
ld (penCol), hl
Of course these are just small things. But in big programs, they can start to add up.
-
And don't forget the header :)
Looking great so far. As a suggestion, how about calculating the actual amount of max RAM? It's not always 24,576 bytes. I think there's a pointer with a certain value that you subtract $9D95 from to get the amount of RAM the user could potentially use. Forgot what it was though.
-
And don't forget the header :)
Looking great so far. As a suggestion, how about calculating the actual amount of max RAM? It's not always 24,576 bytes. I think there's a pointer with a certain value that you subtract $9D95 from to get the amount of RAM the user could potentially use. Forgot what it was though.
I was told in Cemetech it was always 24756 :S And the header is DCS7 only now already.