Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
About
Team
Rules
Stats
Status
Sitemap
Chat
Downloads
Forum
News
Our Projects
Major Community Projects
Recent Posts
Unread Posts
Replies
Tools
SourceCoder3
Other Things...
Omnimaga Radio
TI-83 Plus ASM File Unsquisher
Z80 Conversion Tools
IES TI File Editor
Free RAM areas
Comprehensive Getkeyr table
URL Shortener
Online Axe Tilemap Editor
Help
Contact Us
Change Request
Report Issue/Bug
Team
Articles
Members
View the memberlist
Search For Members
Buddies
Login
Register
Omnimaga
»
Forum
»
Calculator Community
»
Other Calculators
»
Killerplayer's ASM tutorials
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: Killerplayer's ASM tutorials (Read 4090 times)
0 Members and 1 Guest are viewing this topic.
Halifax
LV9
Veteran (Next: 1337)
Posts: 1334
Rating: +2/-1
Killerplayer's ASM tutorials
«
on:
November 27, 2006, 10:13:00 am »
Ok this is Volume 1 Lesson 1 of my EAZYASM tutorials. First off disregard all references to downloading something in the article and just download the things you need from up here. But you NEED to download Assembler, tasm80,tab, ti83plus.inc, and makefile no matter what and put those all in the same directory. And if you are programming for ion then you need ion.inc and if you are programming for mirage then you need mirage.inc
http://www.freewebs.com/omnimaga/assembler.exe
http://www.freewebs.com/omnimaga/ion.inc
http://www.freewebs.com/omnimaga/mirage.inc
http://www.freewebs.com/omnimaga/Tasm80.tab
http://www.freewebs.com/omnimaga/ti83plus.inc
Ok this is Killerplayer's tutorial and it is going to give it to you and I don't care what you think about how I do it. I will do whatever the **** I want and you have to just go with it and trust me ok?. Ok. Now on to the tutorial.
----------------------
Things you should know
----------------------
All code will be put between **************** that
e.g
************************
Assembly code goes here
************************
ok
All explanations of important stuff is put between =====================
e.g
==========================
Important stuff goes here
==========================
and that is all you need to know because the rest is just me explaining things you should know.
All chapters are put in ----------------- that
To the Assembly tutorial
-------------
UNDERSTANDING
-------------
Ok breath a sigh of relief because I am not going to make you setup your own Assembly environment I am going to give it to you. No it is not tasm because
TASM sucks
and SPASM rocks. The link is below and all you need to do is download and extract it to some place on your computer where you want to use it. To assemble something you right click on the .bat file and switch everything that says "test" with the name of yor sourcefile.
E.g
If I wrote all the code in myprog.z80 I would open up the .bat file and replace everything that says test with myprog and then save and exit. Next I would double click the .bat file and it will bring up a DOS window that tells if you have errors or not.
The screen will look like the if you have named your sourcefile test.z80
=====================================================
assembler test.z80 test.bin
Spencer's Assembler, June 2006
Pass 1 ...
Done.
Pass 2 ...
Done.
wabbit test.bin test.8xp
Picture comes up with credits
test.8xp (xxxx bytes) was successfully generated!
pause
Press any key to continue . . .
=======================================================
This screen will only appear if your source code has compiled correctly.
Ok so that is all you need to know about compiling. On to the next chapter
------------------------------------
Am I developing for a shell or TI-OS
------------------------------------
Ok just some little info is someone says something about "nostub" programming than that means the same as programming for the TI-OS.
Now ask yourself do you want to program for a shell or for the TI-OS
If you are programming for MirageOS or Ion download this.
That include ion.inc and mirageos.inc so you can develop for a shell and also it has ti83plus.inc and you need that if you want to use "bcall()" talked about later.
If you are programming for TI-OS then just delete mirage.inc and ion.inc in the previous link and vola.
now you can't just use ion.inc and expect your program to turn up in MirageOS or Ion because you need a header to make sure the shell sees the program.
Ion header needed
=============================
.nolist
#include ion.inc
#include ti83plus.inc
.list
.org progstart-2
.db $BB,$6D
ret
jr nc,start_program
.db "Test",0
start_program:
your program goes here
.end
END
==============================
Ok so you probaly don't understand that well I am going to break that down so you can understand it by commenting the source. Commenting the source is when you put a ; and then type your comment or explanation after it. You can only put a comment after a ; because that makes the compiler ignore what you write after it. Usually comments are to help you remember what you are doing if you have taken a break.
Ion header revised
==============================
.nolist ;This tells the compiler not to compile this
#include ion.inc ;This is needed for Ion programming
#include ti83plus.inc ;This is need for TI-OS programming and Ion programming
.list ;This tells the compiler to compile now
.org progstart - 2 ;this tells the compiler to start at this address
.db $BB,$6D ;This is the Asm token "AsmPrgm" and is needed always
ret ;this makes Ion detect your program
jr nc,start_program ;this tells ion at which label to start at
.db "Test",0 ; THis is the name that is displayed in Ion
start_program: ;this is the label where you told Ion to start at
your program goes here
.end ; tells compiler to stop compiling
END ; ends your program
================================
Ok so you will need to use that if you are programming for Ion. Next we will see what header we use for MirageOS
!!Note that Ion programs are also detect but MOS!!
MirageOS header
=================================
.nolist
#include mirage.inc
#include ti83plus.inc
.list
.org progstart - 2
.db $BB,$6D
ret
.db 1 ;This makes MirageOS recognizes you program
.db %00000000,%00000000 ;this is the icon that is displayed by MirageOS
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
Description:
.db "Test",0 ;This is the description displayed at the bottom of MirageOS
start_program:
program goes here
.end
END
======================================
Ok so there rele is nothing new there except .db 1 and the icon
TI-OS programming header
======================================
.nolist
#include ti83plus.inc
.list
.org progstart - 2
.db $BB,$6D
start_program:
program goes here
.end
END
=======================================
That is a very simple header right. Ok now you have headers for TI-OS and the two premiere shells for Assembly programs so let's move on now.
!!!Note: From now on if I say use Ion header and write this program that means write whatever is in the code brackets into the program goes here part and the same goes for MirageOS and TI-OS!!!
e.g
If I say
Program: Use Ion Header
************************
ld a,5
ld b,5
************************
Then it should look like this
============================
.nolist
#include ion.inc
#include ti83plus.inc
.list
.org progstart-2
.db $BB,$6D
ret
jr nc,start_program
.db "Test",0
start_program:
ld a,5
ld b,5
.end
END
=============================
Ok now we move on
--------------------------------------
Do I really need to learn some math???
--------------------------------------
Stop your whining it isn't that hard. Haha.
Your going to need to learn some number systems named "Binary" and "Hexadecimal". I am assuming you know deciaml if you understand this number 10243.
Decimal is the everyday number system so I will not explain it to you
Binary is not so let's get to it
=====================
Binary Number: 1101
So what does that equal in our everyday system DECIMAL Killerplayer.
Simply do this
Num. value| 8 | 4 | 2 | 1|
________________
Bin. value| 1 | 1 | 0 | 1 |
Ok now let's imagine 1 is on and 0 is off. So that means
Num. value 1 is on
Num. value 2 is off
Num. value 4 is on
Num. value 8 is on
So now let's add up all of the on values
1+4+8 = 13 so that means binary num. 1101 = decimal num. 13
1101 = 13
13 = 1101
Now let's say your decimal number is bigger than four digits like 8 digits
Binary Number: 11010110
Num. vaule| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
______________________________________
Bin. value| 1 | 1 | 0 | 1 | 0 | 1 | 1 | 0 |
Ok now add up all of the on values
11010110 = 214
Ok so if you hadn't notice the num. value multiples itself by 2 as it moves to the left so if you had a 9 digit binary number then the leftmost num. value would = 128X2 and so on.
=============================
Ok so that is it for binary numbers and you should understand that pretty readily. No it is on to hexadecimal.
===============================
Ok Hexadecimal is fairly different because it has 16 numbers hence the "Hexa" prefix.
Hexadecimal "Numbers":
1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
Ok woah Killerplayer you said it was numbers so what does A and B equal
I will explain that...
1=1,2=2,3=3,4=4,5=5,6=6,7=7,8=8,9=9,A=10,B=11,C=12,D=13,E=14,F=15
There you go.
So now let's convert a hexadecimal value to decimal
Hexadecimal Number: 1A3F
Num. value| 4096 | 256 | 16 | 1 |
______________________
Hex. value| 1 | A | 3 | F |
Ok so the num. value get's multiplied by 16 every time it moves to the left. Now the value in Hex. value position 1 is F. So we will do the following
F=15 so 15*1 = 15
3=3 so 3*16 = 48
A=10 so 10*256 = 2560
1=1 so 1*4096 = 4096
Let's add up all the sums 1A3F = 6719
Hexadecimal is as easy as Binary
====================================
In assembly if you are using a binary number you write %10010101 and if using hex write $1F3A and if you are using decimal there is no prefix.
Ok so this lesson is done let's get as far away as we can from numbers.
--------------------
The registers
--------------------
The registers are used for accessing data and all that great stuff that makes up a program
e.g in BASIC you have vars like the whole alphabet among others but in ASM you have "virtually" 8 registers that you can use.
===============
8 bit registers
A, B, C, D, E, F, H, L, and IX
A is like the multipurpose register that is used for almost everything
B is usually used as an 8 bit counter
C is used for interfracing with hardware ports
F is used for flags
D is multipurpose
E is multipurpose
H is multipurpose
L is multipurpose
16 bit registers
AF, BC, DE, HL, IX
HL is like register A's brother in that it is it's 16 bit counterpart
BC is like register B's brother because it is used as a 16 bit counter
DE holds the memory address of a location e.g. DEstitnation
IX is acceptable anywhere HL is but it is bigger and slower and should only be used when HL is tied up
If you store something in HL you will mess it up if you store something in L or H because 16 bit registers are just 8 bit registers are combined so jsut remember that.
==================
Person: Well how do you get stuff into those registers Killerplayer?
Me: Just use a simple function duh!!
Person: Well I didn't know that you *******
Me: Oh yeah sorry I forgot to explain it let me tell you
There is a little function and possibly the most used in any ASM program and that is
LD
Now for all you BASIC people out there you are familiar with load
====================
5->J in basic is like
source->variable
so in ASM it is
ld a,5
or
ld variable,source
====================
Ok so what are all the functions load can do
loads or ld's functions(imm8 = immediate 8 bit value imm16 = immediate 16 bit value)
====================
ld a,a
ld a,b
ld a,c
ld a,d
ld a,e
ld a,h
ld a,l
ld a,(BC)
ld a,(DE)
ld a,(HL)
ld a,(imm16)
ld a,imm8
ld b,a
ld b,b
ld b,c
ld b,d
ld b,e
ld b,h
ld b,l
ld b,(HL)
ld b,imm8
register C does everything register B does
register D does everything register B does
register E does everything register B does
register H does everything register B does
register L does everything register B does
ld bc,(imm16)
ld bc,imm16
register DE does everything register BC does
register HL does everything register HL does
ld (bc),a
ld (de),a
ld (hl),a
ld (hl),b
ld (hl),c
ld (hl),d
ld (hl),e
ld (hl),h
ld (hl),l
ld (hl),imm8
ld (imm16),a
ld (imm16),bc
ld (imm16),de
ld (imm16),hl
=========================
That is all the things that load could ever do on the TI z80 processor
You don't know what the () means but that doesn't matter right now
examples of what load can d
===========================
ld a,2 store 2 into register a
ld d,b store value in register b to register d
ld ($9240),a store value of register a to memory location
===========================
There is one thing that ld can not do and that is load 16 bit registers into 16 bit registers, but there is a way to do this. Let's say we want to load hl into de. We can't do ld de,hl. We have to do the following.
=========
ld d,h
ld e,l
=========
Ok so what values can these registers hold do they have any limits. Well yes they actually do have some limits 8bit registers can only hold values -255 to 255 and 16bit registers hold values -65536 to 65536.
!!Note registers F and AF cannot be used for ld or any instructions except a few!!
Ok so we are done with registers right now
ld d,h
ld e,l
=========
Ok so these registers have limits though.
8bit registers can hold values -256 to 256
16bit registers can hold values -65536 to 65536
Now we are done with registers basically
------------------------
Negative Numbers in ASM
------------------------
Negative Numbers are not as hard as some people may lead you to believe.
Let's imagine negative numbers in real life.
-5 = -5 right
well in ASM 0 = 0 and 0 = 256.
So let's say that we store -5 into register A then register A is actually holding
256 - 5 = 251
what happens if you put -5 into hl
65536 - 5 = 65531
so 65531 will be in register HL then
So you will need to know this. When you assemble your programs and compare numbers you can check for -5 by typing -5 but if you display the number on screen in your code and you run the program it will show 251 not -10
Ok well that is the end of Volume 1, Lesson 1 Thanks for checking out my tutorial if you have any questions then just post them. Volume 1, Lesson 2 coming soon
http://www.freewebs.com/omnimaga/make.bat
Logged
There are 10 types of people in this world-- those that can read binary, and those that can't.
tifreak
LV11
Super Veteran (Next: 3000)
Posts: 2708
Rating: +82/-3
My Kung Fu IS strong...
Killerplayer's ASM tutorials
«
Reply #1 on:
November 27, 2006, 10:52:00 am »
Some easy reading...
Good job! Any chance you would allow me to host it in html format on TI-Freakware?? The 83+asm section is very much empty at the moment...
Logged
Projects: AOD Series: 75% | FFME: 80% | Pokemon: 18% | RPGSK: 60% | Star Trek: 70% | Star Trek 83+: 40% | TI-City: 5%
elfprince13
Guest
Killerplayer's ASM tutorials
«
Reply #2 on:
November 27, 2006, 11:16:00 am »
nice tutorial format, easy explanations, coupla things,
explain how the headers work, not just how they are formatted, teaching people that its "magic" is not what we want.
explain that there are other shells than MirageOS.....
base 16 is "hexadec"imal not "hexa"decimal.
while your at it explain the theory behind different radixes (numbering systems) using examples from binary, octal, decimal, hexadecimal, and then something wierd like ternary or unadecimal.
next off, explain that the z80 is little endian, this is CRITICAL.
your math on the min/max values for a register are off, ie, 8 bit registers can hold -255 OR -128-127.
add a link to a more advanced tutorial such as CoBB's Independent z80 Guide, or Sigma's 83pasm28d for the more technical audience.
Logged
Halifax
LV9
Veteran (Next: 1337)
Posts: 1334
Rating: +2/-1
Killerplayer's ASM tutorials
«
Reply #3 on:
November 27, 2006, 11:21:00 am »
I will explain the headers more in the next volume but I will not really change anything else because I feel this tutorial is "as is" and people can find Sigma's tutorial on there own and have and said it was hard to understand so that is what drove me to write this tutorial but yea you are right I messed up on the values
@ TI-Freakware go ahead
Logged
There are 10 types of people in this world-- those that can read binary, and those that can't.
elfprince13
Guest
Killerplayer's ASM tutorials
«
Reply #4 on:
November 27, 2006, 11:27:00 am »
aha, another thing, explain the difference between z80 commands, and assembler directives
Logged
bfr
LV8
Addict (Next: 1000)
Posts: 819
Rating: +4/-0
Killerplayer's ASM tutorials
«
Reply #5 on:
November 27, 2006, 12:34:00 pm »
Looks nice
I know there are a few Z80 tutorials out there, but I think a good one is needed that explains all of the basics really well for beginners and teaches whatever the other tutorials didn't teach.
A few problems though:
1. IX is mentioned as an 8-bit register and a 16-bit register.
2. You said
QUOTE
Ok so these registers have limits though.
8bit registers can hold values -256 to 256
16bit registers can hold values -65536 to 65536
I think you might want to re-check those values.
There might be more, but I just skimmed through.
EDIT:
QuoteBegin
-->
QUOTE
e.g in BASIC you have vars like the whole alphabet among others but in ASM you have "virtually" 8 registers that you can use.
I guess you could say that, but it makes it seem like assembly only has 8 places to store data, at least to me. Assembly pretty much has the entire calculator's memory, including BASIC variables. Maybe there is a better way to put it?
Logged
bfr's website -
http://bfr.tifreakware.net
Halifax
LV9
Veteran (Next: 1337)
Posts: 1334
Rating: +2/-1
Killerplayer's ASM tutorials
«
Reply #6 on:
November 27, 2006, 02:32:00 pm »
@bfr yeah sorry about the ix thing that was wrong and also your giht about me checking the values and stuff but I didn't want to reveal to them yet about using other places to store the data because that is coming in the next tutorial so sometimes it is better to wait and see
Logged
There are 10 types of people in this world-- those that can read binary, and those that can't.
Krid
Guest
Killerplayer's ASM tutorials
«
Reply #7 on:
November 27, 2006, 07:56:00 pm »
Looks nice so far
I'd like to see example programs where you put the code you explained to use. (The best motivation to learn is to see the result)
Logged
DJ Omnimaga
Clacualters are teh gr33t
CoT Emeritus
LV15
Omnimagician (Next: --)
Posts: 55943
Rating: +3154/-232
CodeWalrus founder & retired Omnimaga founder
Killerplayer's ASM tutorials
«
Reply #8 on:
November 28, 2006, 02:52:00 am »
wow nice, I'm pinning this topic now.
And code examples and screenshots would be good
Logged
Halifax
LV9
Veteran (Next: 1337)
Posts: 1334
Rating: +2/-1
Killerplayer's ASM tutorials
«
Reply #9 on:
November 28, 2006, 12:45:00 pm »
Haha everyone is asking for code examples, and this is all coming in due time trust me but there really if nothing to do with the commands I explained that you can "see" with out me introducing some new stuff. And yes this was actually just a beta tutorial to gauge the reactions towards its welcoming but as it seems it has been good so far then I will continue on and add screenshots
Thanks for all the suggestions though the support is really helpful!!!
Logged
There are 10 types of people in this world-- those that can read binary, and those that can't.
Print
Pages: [
1
]
Go Up
« previous
next »
Omnimaga
»
Forum
»
Calculator Community
»
Other Calculators
»
Killerplayer's ASM tutorials