When I started off learning 83 TI-BASIC, I wondered what it was like to program in something like assembly or AXE. I always saw ASM as some super difficult language but I never made any attempt to learn it.
But after I learned more popular languages like Python and C, and how relatively simple they were, they inspired me to take the plunge and finally learn how to write games and programs in ASM.
Today I made my first ever ASM program with the help of Fghsgh and Calc84maniac. Womp Womp said I should make a thread that documents my progress with learning ASM.

Today marks the start of my journey in learning Z80 Assembly, hopefully by the end of this I will be able to make fun games and useful programs!!
Without further ado...

June 22nd 2022
Today I learned how to build and use SPASM and the basic syntax of ASM. I used Visual Studio Code to create the source code of the program with the help of Liberal_Eater's syntactic highlighting extension.
I then learned that the Mathprint feature causes some bugs with the PutS function. After that, I tested out the program with the jsTIfied emulator.
Well done!

Always great to see someone starting out with ASM.

My suggestion is to read up on the hardware and OS via the wiki: https://wikiti.brandonw.net/index.php?title=Calculator_Documentation

And to check out programs with src on ticalc.org or github and to 'start at the start' so the speak without trying to make someone overly complex right off the bat.

And of course to ask any questions on the forums or in the chat Very Happy.
Thanks!

It'll be a long and difficult journey but I am sure it'll be worth it.
And yeah, I will read up on the wiki, I heard from many programming communities, ASM becomes easier the more you understand the underlying hardware.
And I will check out the source code of many programs, I am visual learner and I'd rather learn from examples then to read a ton of tutorials.

And I will not hesitate to ask any questions, I am very lucky compared to early Z80 ASM programmers in the sense that I have access to many resources online while they only had the official documentation to work with.
Graphing Calculator
Good on you for taking the challenge! Being the nostalgic old guy that I am, I'll enjoy re-living the learning Z80 experience through what you post here Smile

And like tr1p1ea said, don't be afraid to reach out if you have questions.
July, 24th, 2022
After 1 month of on-and-off learning I am here to update you on my progress.
First things first, I got the actual PDF of the Z80's manual! I am sure it will be of great service to me!
Also not to mention, I love reading about computers!
While I haven't been making any actual programs
I have been studying the "Hello, World" program and seeing what makes it tick.
I also learned that the Z80 has no multiplication and division instruction. I feel like it's ironic how the
Z80 is used for so much calculators but can't do any 3rd grade math without routines.
I also learned the basic ideas on what "registers" are.
Thanks for those who are helping me on this presumably long and painful journey. Smile
Good for you! ASM is my absolute favourite; if I had more free-time on my hands I'd want a go at making a game using x86 assembly.

I have just one thought: Writing a game for a Ti-calculator is a fun challenge balancing speed and program size. For things that require speed -- drawing sprites or a tilemap -- B_CALL routines are not a good idea. For things that don't have to be fast -- searching for an appVar, archiving a program or displaying a main menu -- B_CALL routines are your best friend.

Examples:
B_CALL DisplayImage -- I wouldn't touch this once you learn how to draw sprites / splash screens
B_CALL ChkFindSym -- There's every reason to use this one to find AppVars instead of making your own routine
B_CALL GetKey -- Very good for "press any key to continue" routines, not good for actual gameplay
I have just started learning z80 asm (for my TI 83) and I have some questions. When you do stuff like call_putS, where are you actually going? I get how SPASM knows, but I would kind of like to know so I can just type in the hex on calc. Also, does anyone have a list of the memory-mapped ports for the screen and stuff, so I can write own libraries?

EDIT: Sorry for not doing the research before, I found the ports for the screen and a few other things at the link posted earlier here, at <href a=“Wikiti.brandonw.net”>this site</href>.
sJRw wrote:
I have just started learning z80 asm (for my TI 83) and I have some questions. When you do stuff like call_putS, where are you actually going? I get how SPASM knows, but I would kind of like to know so I can just type in the hex on calc. Also, does anyone have a list of the memory-mapped ports for the screen and stuff, so I can write own libraries?

EDIT: Sorry for not doing the research before, I found the ports for the screen and a few other things at the link posted earlier here, at <href a=“Wikiti.brandonw.net”>this site</href>.


Yes, you're correct. If you have just a regular TI 83, you can find all the hex codes / memory addresses for the call routines here:

https://wikiti.brandonw.net/index.php?title=Calculator_Documentation

Same thing for the TI-83+, but instead of call $4000 ($CD $00 $40) you have to use B_CALL $4000 ($EF $00 $40)
Congratulations on stepping into assembly, and good luck on your journey! Don't forget to post any questions that you get stuck on here, and I also recommend reading plenty of existing code as a good way to learn.
sJRw wrote:
I have just started learning z80 asm (for my TI 83) and I have some questions. When you do stuff like call_putS, where are you actually going? I get how SPASM knows, but I would kind of like to know so I can just type in the hex on calc. Also, does anyone have a list of the memory-mapped ports for the screen and stuff, so I can write own libraries?

EDIT: Sorry for not doing the research before, I found the ports for the screen and a few other things at the link posted earlier here, at <href a=“Wikiti.brandonw.net”>this site</href>.

Hot_Dog has already answered your question, but I'll just add one note from my own experience many years ago: whilst it's fun and does feel good to be able to write Hex straight into the calculator, it will become less practical once you start to extend beyond simple programs. Any time you want to JP or CALL within your program, you'll have to manually work out the address, and this address will change each time you modify something earlier in the program.

But yeah it is fun/cool to do, as long as you don't crash and lose your code! Smile
Thanks. I was planning on using just relative call routines, then I realized that you can only go -126 to 129 bytes. I would love to do something like make my own compiler, but I don't have the 38k cord. Does anyone have a link to that?
September 5th, 2022

Sorry for not replying to your replies! I forgot!
But I did learn a lot since July, I learned how to use registers with instructions like ADD and LD and how to make my own variables.

Before that I did learn what each bit of the Hello World program does.

Not to mention I also learned what the F register does and what flags are and how to use them to create conditional loops. So far there has nothing that straight up confuses me, except the "carry" flag but I have mostly wrapped my head around that.
I am very excited to learn the rest of ASM!! It's been slow progress but at least I am understanding everything. Thanks everyone for the help! Graphing Calculator
Hamburger317 wrote:
September 5th, 2022

So far there has nothing that straight up confuses me, except the "carry" flag but I have mostly wrapped my head around that.


Here's my attempt at clarifying the carry flag with an example: As you probably read, a one-byte register such as A can hold a value from 0 to 255. Let's say A = 250. If you use the instruction "ADD A, 5", the carry flag will be reset, meaning your add instruction didn't cause you to exceed the maximum value for the register A. But if you use "ADD A, 7," that's over the limit, because A cannot be equal to 257. In that case, A = 1 and the carry flag is set, telling you that you went over the limit.

Similarly, if A = 3, "SUB 2" resets the carry flag, but "SUB 8" sets the carry flag.

A practical use: Let's say you're re-making the original "Metroid," where a player can only have 255 missiles.


Code:

PlayerCollectsMissilePack:

 ld a, (NumberOfMissiles)
 add a, 5
 jr nc, GoodNumberOfMissiles  ;If the carry flag is reset, we are not trying to give the player
                                             ;more missiles than he is allowed to hold.

 ;Oops, the player wants to have more than 255 missiles.  We cannot allow that.

 ld a, 255

GoodNumberOfMissiles:
         
 ld (NumberOfMissiles), a   
 ret

Hamburger317 wrote:


A couple of things..

- Lines 2 & 3: PenCol by itself is a 1 byte location, which is followed by PenRow. So doing the ld hl,0 \ ld (PenCol),hl is setting both (PenCol) and (PenRow) to 0.

- Pencol is actually used for routines such as _VPutS (printing in the smaller variable width font). For the homescreen text printing you're doing with _PutS, you want to use CurRow and CurCol. You can reset both to 0 in one hit by doing ld hl,0 \ ld (CurRow),hl similar to what you had in your code.

- It's important to remember that in the memory layout, PenCol precedes PenRow, but CurRow precedes CurCol.

- Finally - and now I'm just being picky - but I think it helps to understand Smile The ld hl,msg isn't so much as loading the message into the HL register, it's more that HL contains the address of the string data, ie. HL is acting as a pointer for the _PutS routine.
JamesV wrote:
Hamburger317 wrote:



- Finally - and now I'm just being picky - but I think it helps to understand Smile The ld hl,msg isn't so much as loading the message into the HL register, it's more that HL contains the address of the string data, ie. HL is acting as a pointer for the _PutS routine.


He's right, and as you probably know, an address allows you to directly manipulate the RAM where your message is stored. Just for fun and as a learning experience, you might see what happens when you use "ld hl, msg + 1." Then for more fun, you could try the following:

ld hl, msg
ld (hl), 'Z'
bcall(_PutS)
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement