For a week or two, I've had this thought about making another Z80 assembly tutorial. At the moment, the best tutorial out there is Asm In 28 Days, but I've heard complaints regarding its usability for new people for actual learning material. Sure, it makes a wonderful reference but the one thing I've found is that it doesn't have workable, testable examples and things that one can be done to help reinforce learning. I don't know about most of the other people out there, but I learn best by doing, and the tutorial I want to make will cater to that sort of crowd.

I started writing a sort of road map concerning the topics that should be discussed, and in what order to present them in. I figured that if I want to actually write a tutorial, I'd best have an outline first before announcing anything since an announcement in and of itself isn't all that helpful in getting this idea off the ground.

This is what I have after a bit of thinking. Comments and suggestions appreciated.

Note: I could not figure out how to get preformatted text working. The code tag was the closest I could find but the colors. pre did not work. mono didn't preserve the spacing.


Code:
Z80 Assembly Tutorial For the TI-83 Plus (SE)
Centered around creating a simple game, then making it run faster. Better.
Each section should have DIY tasks to help them understand a concept better.
Subsections explaining actual instructions will be indexed in a different color.

* Introduction
   What ASM is, isn't, what it takes to learn, and tutorial methodology.

* Development Environment
  - Assemblers and getting your first binary (.8xp) assembled.
  - Link software if you have actual hardware
  - Emulators and how to use them.

* Numbers, Variables, and Memory
  - A forward. All these topics will involve the use of the LD instruction and
    its many variations.
  - Numbers
    - Discussion on decimal, hexadecimal, and binary and why to use them.
    - A short note on octal and that it was historically used.
  - Variables
    - Discussion of registers and their short term scope
      - A short note on other special purpose registers and their functions
    - Short discussion about the stack and its longer but still short term scope
    - Discussion of SafeRAM and their scope in-program.
    - Discussion of files and their persistence after a program ends.
  - Memory
    - What memory is, and the different types on the calculator
    - Memory maps and address range
    - A listing of various stretches of safeRAM on the calculator
    - Memory access is just another number. Talk about indirection here.
  - Hardware
    - Very short explanation that additional hardware such as keyboard, memory map
      ports or LCD are accessed via IN/OUT instructions. Each has their method of
      access, and is only briefly mentioned here because memory was discussed.

* System Calls
  - A short section on what a bcall is.
  - Locations and places of references for said system calls.

* Something Useful - Messing Around With Text
( Should showcase all manners of LD instructions and use here )
  - Introducing useful romcalls for messing with the homescreen.
  - A reminder that romcalls can and will mess around with the contents of registers
    and that registers are for SHORT TERM STORAGE.
  - Displaying a string.
  - Introduce the CALL/RET instructions for subroutines
  - Displaying one character at a time
  - Introduce math instructions (ADD/SUB) (INC/DEC)
  - Displaying numbers from registers

* Key input
  - Introduce program control flow via CP/JP
  - Introduce system calls for getting key input, link to reference table
  - Have the user do stuff with keypresses to make the program display different things
  - Implement text "sprite" onscreen and move it around.
  - Introduce and explain z80 FLAGS
    - Tie in this knowledge with math instructions
    - Using that knowledge, implement movement boundary checking

* The Graph Screen and Graph Buffer
  - Introduction to graph buffer and the separation between that and the LCD
  - Displaying text on the graph buffer.
    - Re-implement text sprite on graph buffer
  - Using system calls to draw lines and boxes onscreen
  - Introduction to sprites and the many methods of drawing them to screen
    - Will use ION sprite routine as basis. Its operation will not be explained yet.
    - A note that this topic will be re-visited later on to support clipping

* The Stack
  - Introduction to what the stack is and what it's used for
  - Introduction to PUSH/POP
    - Explanation of push/pop procedures.
      - Upgrade previous program with it.
    - Explanation of CALL/RET and how it messes with the stack
  - Explanation of EX (SP),HL and its use
  - Short explanation of direct stack manipulation
    - Note on how this is generally used to create an exit-from-anywhere point.
    - Caveats about using SP in a manner other than for call/variable stack purposes
      - Link forward to interrupts section if student really wants to abuse SP

* Arrays and Jump Tables
  - Arrays and what they are
    (Now would be a great time to discuss indirection
    - How to read/write to/from them
    - Methods of managing them (if at all)
      - Great place to introduce block copy instructions (LDI[R]/LDD[R])
      - At this point, we can create a graphscreen game
        based on avoiding other moving objects
  - Jump tables
    - What they're for
    - Jump tables filled with 2-byte addresses
    - Jump tables filled with 1-byte offsets

* Bitmasking and Bit Math
  - Introduction to system flags and BIT/SET/RES instructions
    - Messing around with inverting text and those various flags.
      - While we're at it, accelerate text drawing by making vputs routines buffer-only
  - Introduction to the zillions of rotate/shift instructions available on the z80
    - Might as well introduce direct keyboard reading now
      - Shifting and rotating results out to carry seems like a great method to use.
      - Upgrade the game with this.
  - Introduction to AND/OR/XOR instructions
    - Methods of bitpacking so varibles take up less space
    - Setting, resetting, or testing multiple flags at the same time
    - Bitmasking and examining how ION's sprite routine works

* Interrupts
  - Explanation of what interrupts are and how they may be useful
  - Enable, disable, and create and clean up after interrupts
    - Hardware differences that influence this on the SE's and 84's

* LCD and Direct Access
  - Details of the screen itself and manner of access via ports including delays
  - Reference of commands and things you can do
  - Introduction to ION's fastcopy routine
  - Introduction to grayscale. How to abuse interrupts and slowness of LCD to achieve
 
* Accessing Variables Outside Your Program
  - List of what a file is and the various filetypes on the calc
    - Details of each file type and their use
  - Romcalls used to check for, access, create and delete variables
    - With this, perhaps we can create an external high score file?
    - How to resize variables if you weren't sure how large they ought to be on create
  - Explanation of what the VAT is and how to traverse it
  - Explanation of how to access archived variables without unarchiving them first

* Use of TI's Floating Point Structures
  - An overview of what floating point numbers are, and a quick note on fixed-point
    - None of our examples will use them, but this topic is covered for completeness.
      Perhaps you'll get an idea that requires decimal precision and this works.
      That circular version of the worm game comes to mind.
  - Details of TI's floating point format
  - Available romcalls for moving floats and float-sized data.
  - Available romcalls for manipulating the Floating Point Stack (FPS)
  - Available romcalls for mathematical purposes

* Fixed Point Mathematics and Mult/Div routines
  - What fixed point math is and why it may be better to use it
  - Outline of multiplication
    - Naive method
    - Faster multiplication method and why it works
  - Outline of division
    - Naive method
    - How to use fixed point math ideas to multiply by reciprocal instead.
      - Division is slow and awkward. This is a way to avoid it
    - Faster division algorithms and why they work.
      - Oh gawd. I am NOT looking forward to this section.

* Creating Flash Applications
  - What Flash Applications (FlashAPPs) are and why to use them
  - Changes to the dev environment to support FlashAPPs
  - Differences that must be observed (e.x. how to exit flashapps, no SMC, etc.)
  - Multipage FlashAPPs
    - Doing it TI's way, through the use of an in-app bcall table.
    - Doing it our way, through the use of a pagechange stub.
      - Might as well introduce how to mess around with memory mappings here.
      - Also discuss cross-page access

THIS IS WHAT I HAVE SO FAR.
CHERRIES FOR EVERYONE.
Sweet, sounds right up my ally (learning by doing)! I think it's a great idea, and there's never anything wrong with competition among tutorials.
I hope it includes z80 ASM for the ti 84 plus CSE. What's it going to be called and when is it going to be released?
I would also recommend a section on debugging. Sometimes the hardest thing to figure out it way something isn't working the way it should. Smile

Good luck on this project; I imagine that it is going to take quite some time to compile!
I will happily be your test subject for lessons if you like, as I'm still learning things, and learn as you do, I'd be great Very Happy
This sounds like a great idea. I've been wanting to work on a more game-oriented tutorial for a long time.
As I mentioned on IRC when you first discussed this project, I'm glad to hear you'll be working on a new tutorial, and I hope you might also consider integrating some of the information you think would be useful to any new z80 ASM programmer into the improved ASM in 28 Days version we're developing. From what you described of the first few lessons, teaching something like a simple game where you move a character around in order to introduce calls, bcalls, registers, basic register math, program structure, use of assemblers and emulators, proper code structure, and proper commenting, it sounds like you've thought this out well. I'm also glad that unlike a certain other tutorial that I've spoken out against in the past, you'll be teaching hexadecimal and bitmath. Wink

Good luck!
As always if ya need my help mate I am here. You taught me so you know what I know! I shall try to keep you sane(ish) Razz
  
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