Author Topic: Memory Checker - My first ASM program  (Read 3537 times)

0 Members and 1 Guest are viewing this topic.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Memory Checker - My first ASM program
« on: May 28, 2011, 07:31:32 am »
I finished my first useful ASM program:

Code: [Select]
; 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?

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Memory Checker - My first ASM program
« Reply #1 on: May 28, 2011, 09:28:27 am »
Ouch. You forgot something very important! The header!
I'm not a nerd but I pretend:

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Memory Checker - My first ASM program
« Reply #2 on: May 28, 2011, 09:52:17 am »
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:
Code: [Select]
  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.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Memory Checker - My first ASM program
« Reply #3 on: May 28, 2011, 09:56:40 am »
This:
Code: [Select]
ld a,1
  ld (penCol), a
  ld a,1
  ld (penRow), a
could be
Code: [Select]
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)
I'm not a nerd but I pretend:

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Memory Checker - My first ASM program
« Reply #4 on: May 28, 2011, 09:58:24 am »
Which could be further optimized to:
Code: [Select]
ld hl, 1*256+1 ;penRow * 256 + penCol
ld (penCol), hl
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Memory Checker - My first ASM program
« Reply #5 on: May 28, 2011, 10:00:55 am »
Yeah, thats true. You can use that in Axe too. ( Text(Y*256+X) \ Text "STRINGHERE" )
I'm not a nerd but I pretend:

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Memory Checker - My first ASM program
« Reply #6 on: May 28, 2011, 03:12:20 pm »
I made some updates, what do you think?

Code: [Select]
; 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:

Code: [Select]
; 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
« Last Edit: May 28, 2011, 03:51:40 pm by Scout »

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Memory Checker - My first ASM program
« Reply #7 on: May 28, 2011, 04:12:26 pm »
Looks good, the last thing you should do to bring it up to optimized is change things like
Code: [Select]
;4 bytes
ld d, 95
ld e, 5

;to

;3 bytes
ld de, 95*256+5

And also
Code: [Select]
;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.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

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: Memory Checker - My first ASM program
« Reply #8 on: May 28, 2011, 04:22:11 pm »
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.
« Last Edit: May 28, 2011, 04:22:23 pm by Deep Thought »




Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Memory Checker - My first ASM program
« Reply #9 on: May 28, 2011, 04:29:03 pm »
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.