Okay, so I've decided that it is finally time to learn z80 assembly! Following the recent boom in creation of topics like this, I began a thread. I'm going to read more into the 28 days tutorial tomorrow (more than the first page Razz), but for now I figured that I should get this started and bookmark my post so I don't forget it. (xD) For now, I'm using a sloppily modified version of the DCS SDK "environment." It will be a much cleaner mod very soon, however. At the moment it is CLI, but I am satisfied with the results, despite the sloppy coding (I was rushing to be able to start coding).

So... to actually begin this topic, I'm curious as to what kind of programs everyone believes a beginner should start making.

Also: source code from my first program (mainly from viewing other learning topics)!

Code:
.nolist
#include "ti83plus.inc"
#include "dcs7.inc"
.list
.org $9D93               ;I understand Kerm doesn't like 40339, and I don't either.
.db t2ByteTok,tAsmCmp
Start:
   bcall(_clrLCDFull)
   ld hl,(0*256)+0
   ld (CurRow),hl
   ld hl,msg
   bcall(_PutS)
   bcall(_getKey)
   bcall(_ClrLCDFull)
   ret

msg:
   .db "Cr-48s are over-"
   .db " rated, aren't  "
   .db "     they?      "
   
.end
.end


And finally, my coding environment (Note: This *was* just for me, so I use some paths in MY %USERPROFILE%):

  • z80 Command Prompt

    Code:
    @echo off
    title z80 Assembly Compilation Prompt
    cd "C:\Users\TechnoMonkey76\Documents\z80 Programming"
    echo Type "z80comp" to compile a program, or...
    echo Type "z80edit" to modify an existing program!

  • z80 Compiler (from SDK, sloppily modified; beware)

    Code:
    @echo off
    cls
    echo ----------------------------------
    echo    Doors CS Assembler\Compiler   
    echo           Version 2.0         
    echo      Written by Kerm Martian     
    echo      http:\\www.Cemetech.net       
    echo ----------------------------------
    echo ----- Assembling for the TI-83/84 Plus...
    echo #define TI83P >tasm\zztemp.asm
    @echo off
    set CURRDIR=%CD%
    :: First test to see if we are on NT or similar OS
    :: The ony difference is how they handle the ampersand
     > ~userin.vbs echo 1234&rem
    type ~userin.vbs | find "rem" > nul
    if errorlevel 1 goto WINNT
    goto WIN9X

    :WIN9X
     > ~userin.vbs echo strUserIn = InputBox("Source File to Assemble (minus extension) ")
    >> ~userin.vbs echo Set fs = CreateObject("Scripting.FileSystemObject")
    >> ~userin.vbs echo strFileName = fs.BuildPath(Wscript.ScriptFullName & "\..", "~userin.bat")
    >> ~userin.vbs echo strFileName = fs.GetAbsolutePathName(strFileName)
    >> ~userin.vbs echo Set ts = fs.OpenTextFile(strFileName, 2, True)
    >> ~userin.vbs echo ts.WriteLine "set userin=" & strUserIn
    >> ~userin.vbs echo ts.Close
    goto RUN

    :WINNT
     > ~userin.vbs echo strUserIn = InputBox("Source File To Assemble (minus extension)")
    >> ~userin.vbs echo Set fs = CreateObject("Scripting.FileSystemObject")
    >> ~userin.vbs echo strFileName = fs.BuildPath(Wscript.ScriptFullName ^& "\..", "~userin.bat")
    >> ~userin.vbs echo strFileName = fs.GetAbsolutePathName(strFileName)
    >> ~userin.vbs echo Set ts = fs.OpenTextFile(strFileName, 2, True)
    >> ~userin.vbs echo ts.WriteLine "set userin=" ^& strUserIn
    >> ~userin.vbs echo ts.Close
    goto RUN

    :RUN
    :: Now run the created script
    start /w wscript.exe ~userin.vbs
    del ~userin.vbs

    :: Now call the created batch file
    call ~userin.bat
    del ~userin.bat
    if exist %USERIN%.asm type %USERIN%.asm >>"C:\Users\TechnoMonkey76\Programs\z80 Dev\DCS SDK\asm\tasm\zztemp.asm"
    if exist %USERIN%.z80 type %USERIN%.z80 >>"C:\Users\TechnoMonkey76\Programs\z80 Dev\DCS SDK\asm\tasm\zztemp.asm"
    if not exist %USERIN%.z80 (
    if not exist %USERIN%.asm (
    echo Error: File not found!
    pause
    cls
    cmd /K "C:\Users\TechnoMonkey76\Programs\z80 Dev\DCS SDK\asm\z80cmd.bat"
    exit
    ))
    if exist "%USERPROFILE%\Documents\z80 Programming\%USERIN%.8xp" move "%USERPROFILE%\Documents\z80 Programming\%USERIN%.8xp" "%USERPROFILE%\Documents\z80 Programming\%USERIN%.8xp.old"
    cd "C:\Users\TechnoMonkey76\Programs\z80 Dev\DCS SDK\asm"
    cd tasm
    brass zztemp.asm ..\exec\%USERIN%.bin -l ..\list\%USERIN%.list.html
    if errorlevel 1 goto ERRORS
    cd..
    cd exec
    ..\tasm\binpac8x.py %USERIN%.bin
    echo ----- %USERIN% for the TI-83/84 Plus Assembled and Compiled.
    echo TI-83 Plus version is %USERIN%.8xp
    goto DONE
    :ERRORS
    echo ----- There were errors.
    cd %CURRDIR%
    :DONE
    del ..\tasm\zztemp.asm >nul
    del %USERIN%.bin >nul
    cd "C:\Users\TechnoMonkey76\Programs\z80 Dev\DCS SDK\asm\exec"
    copy %USERIN%.8xp "%USERPROFILE%\Documents\z80 Programming\%USERIN%.8xp" >nul
    del %USERIN%.8xp
    cd %CURRDIR%

  • z80 Editor (Just NP++ with a file prompt)

    Code:
    @echo off
    :: First test to see if we are on NT or similar OS
    :: The ony difference is how they handle the ampersand
     > ~userin.vbs echo 1234&rem
    type ~userin.vbs | find "rem" > nul
    if errorlevel 1 goto WINNT
    goto WIN9X

    :WIN9X
     > ~userin.vbs echo strUserIn = InputBox("Source File to Edit (minus extension)")
    >> ~userin.vbs echo Set fs = CreateObject("Scripting.FileSystemObject")
    >> ~userin.vbs echo strFileName = fs.BuildPath(Wscript.ScriptFullName & "\..", "~userin.bat")
    >> ~userin.vbs echo strFileName = fs.GetAbsolutePathName(strFileName)
    >> ~userin.vbs echo Set ts = fs.OpenTextFile(strFileName, 2, True)
    >> ~userin.vbs echo ts.WriteLine "set userin=" & strUserIn
    >> ~userin.vbs echo ts.Close
    goto RUN

    :WINNT
     > ~userin.vbs echo strUserIn = InputBox("Source File To Edit (minus extension)")
    >> ~userin.vbs echo Set fs = CreateObject("Scripting.FileSystemObject")
    >> ~userin.vbs echo strFileName = fs.BuildPath(Wscript.ScriptFullName ^& "\..", "~userin.bat")
    >> ~userin.vbs echo strFileName = fs.GetAbsolutePathName(strFileName)
    >> ~userin.vbs echo Set ts = fs.OpenTextFile(strFileName, 2, True)
    >> ~userin.vbs echo ts.WriteLine "set userin=" ^& strUserIn
    >> ~userin.vbs echo ts.Close
    goto RUN

    :RUN
    :: Now run the created script
    start /w wscript.exe ~userin.vbs
    del ~userin.vbs

    :: Now call the created batch file
    call ~userin.bat
    del ~userin.bat

    if exist %USERIN%.asm set EXT=asm
    if exist %USERIN%.z80 set EXT=z80
    if not exist %USERIN%.z80 (
    if not exist %USERIN%.asm (
    echo Error: File not found!
    pause
    cls
    cmd /K "C:\Users\TechnoMonkey76\Programs\z80 Dev\DCS SDK\asm\z80cmd.bat"
    exit
    ))

    "C:\Program Files (x86)\Notepad++\notepad++.exe" %USERIN%.%EXT%


Both the z80edit and z80comp batch files were compiled into an executable (*.exe), by the way.
The only error I found in your code was that your string needs to be zero-terminated.

Code:
msg:
   .db "Cr-48s are over-"
   .db " rated, aren't  "
   .db "     they?      " ,0       ; <---- notice the zero
Souvik, I love your signature. I see that same error. However, if he adds those, then it's just gonna be one line of text. Text doesn't magically letter-wrap in z80, I'm afraid. Smile


Code:
.org $9D93               ;I understand Kerm doesn't like 40339, and I don't either.

You make Kerm a happy Kerm. As an FYI, you can also do .org progstart. Smile
KermMartian wrote:
Souvik, I love your signature. I see that same error. However, if he adds those, then it's just gonna be one line of text. Text doesn't magically letter-wrap in z80, I'm afraid. Smile


Code:
.org $9D93               ;I understand Kerm doesn't like 40339, and I don't either.

You make Kerm a happy Kerm. As an FYI, you can also do .org progstart. Smile

Thanks for helping already! However, what if I were to just put the 0 at the end of the last line? Would that allow it to wrap correctly?
KermMartian wrote:
Souvik, I love your signature. I see that same error. However, if he adds those, then it's just gonna be one line of text. Text doesn't magically letter-wrap in z80, I'm afraid. Smile


Code:
.org $9D93               ;I understand Kerm doesn't like 40339, and I don't either.

You make Kerm a happy Kerm. As an FYI, you can also do .org progstart. Smile

If he only adds the zero to the last line, the text still wraps.
I like how you load HL into a value in memory -- many people usually forget that this is fair game and instead try to work around it by doing 8 bit values one at a time Razz. It's a good practice to use that, as I is like all life saving instructions, usually an optimization over the alternative.
Ashbad wrote:
I like how you load HL into a value in memory -- many people usually forget that this is fair game and instead try to work around it by doing 8 bit values one at a time Razz. It's a good practice to use that, as I is like all life saving instructions, usually an optimization over the alternative.
Indeed; I pounded that into David and Calcman and aeTIos's topic, so hopefully he saw that. Smile
KermMartian wrote:
Ashbad wrote:
I like how you load HL into a value in memory -- many people usually forget that this is fair game and instead try to work around it by doing 8 bit values one at a time Razz. It's a good practice to use that, as I is like all life saving instructions, usually an optimization over the alternative.
Indeed; I pounded that into David and Calcman and aeTIos's topic, so hopefully he saw that. Smile

I became lost after day 3 in the 28 days tutorial, and am going to try Hot_Dog's tutorial. I understand most of what's after that relatively well, but I'm confused about the flags.

However, despite this, just for future reference, how would I go about using program writeback? I'm going to try to port my pseudo-phone program ASAP, adding REAL contact functionality! Smile It'll then at least have SOME useful property. Razz
Program write back is quite simple. All you have to do is write something to a location in your program, which starts from 9D95h. For example, this code will write back to itself.

Code:
Start:
 ld hl,PlaceToWriteBackTo
 ld a,1
 ld (hl),a
 ret
PlaceToWriteBackTo:
 .db 0 ;This will become a 1


Quote:
I became lost after day 3 in the 28 days tutorial, and am going to try Hot_Dog's tutorial. I understand most of what's after that relatively well, but I'm confused about the flags.

Flags are bits that are set in the F register. They are set when you do a comparison, when overflows occur, or when the last instruction was an addition or subtraction instruction. The most commonly used flags are z (zero) and c (carry), but flags such as p (parity) are also used, especially when dealing with interrupts. You can use flags in many opcodes, such as jp and jr.

This code will compare the A register to the B register, and it will jump to ZeroFlag if the zero flag is set.

Code:

 cp b ;compares A to B, a.k.a If A=B
 jr z,ZeroFlag ;jumps to ZeroFlag if the zero flag is set, which means A is equal to B
 ret
ZeroFlag:
 b_call(_HomeUp)
 ld hl,String
 b_call(_PutS)
 ret
String:
 .db "A is equal to B",0
technomonkey76 wrote:
I became lost after day 3 in the 28 days tutorial, and am going to try Hot_Dog's tutorial.
May we please help you solve your lostness so you don't have to switch away from ASM in 28 Days?

Quote:
However, despite this, just for future reference, how would I go about using program writeback? I'm going to try to port my pseudo-phone program ASAP, adding REAL contact functionality! Smile It'll then at least have SOME useful property. Razz
Basically, you just name some areas of your program, for example:


Code:
StoreAByte:
    .db 0
StoreAWord:
    .dw 0
StoreAn8CharString:
    .db 0,0,0,0,0,0,0,0,0 ;ninth zero is the zero-terminator


I'm going to hope you're using the DCS header on your programs, in which case Doors CS will take care of making the data you write to those named locations end up back in RAM or archive, wherever the permanent copy of your program happens to be hiding.
I think you will enjoy hot dog's tutorial -- I personally didn't need to relearn ASM, as I remembered all of the stuff up through the Advanced level, but I looked over his and it explains the topic very good Smile. It guides you slowly over the stuff such in day 3 of 28 days that it rushes over and 90% of newcomers have trouble with. Good luck! Very Happy
I feel that it abandons much of the "hard" stuff that can be tricky at first but makes ASM much more intuitive, such as hexadecimal and bit math. That's just my personal opinion, though, and many people seem to still like it. Smile
So I should look at it?
calcman wrote:
So I should look at it?
I'd stick with ASM in 28 Days if that's what you're using so far, but I guess it can't hurt to look at as much source material as possible to help you learn.
Well I downloaded it, but when it opens in microsoft word, it is an unreadable mess
ASM in 28 days is a series of HTML files, you should open them in a web browser.
KermMartian wrote:
I feel that it abandons much of the "hard" stuff that can be tricky at first but makes ASM much more intuitive, such as hexadecimal and bit math. That's just my personal opinion, though, and many people seem to still like it. Smile


I see it as more of an "introduction" that leads you to get ready for 28 days -- but it definitely leaves out more complex material, but for a reason. 28 days is horrible starting out with it's learning curve, but if you understand the early concepts the later ones are explained much better and are very worth looking at Wink
souvik1997 wrote:
ASM in 28 days is a series of HTML files, you should open them in a web browser.
Exactly this. Smile The tutorial is also hosted online in several places:

http://eeezor.ec3club.tk/Files/Resources/Tutorials/ASMin28Days/lesson/toc.html
I was talking about the HotDogs's asm tutorial.
calcman wrote:
I was talking about the HotDogs's asm tutorial.


iirc, the files are in .PDF format, so you'll need adobe acrobat to view them Wink
  
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
» Goto page 1, 2, 3, 4, 5  Next
» View previous topic :: View next topic  
Page 1 of 5
» 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