Omnimaga
Calculator Community => TI Calculators => ASM => Topic started by: NikProgrammer on May 04, 2014, 02:26:26 pm
-
Hello. I'm new here and would like learn Hex for z80 Calculators... ASM in 28 days makes me just like that smily :banghead:. Can anybody please help?
-
Of course, but that's a little unspecific.
What's the trouble?
-
If you want to learn hex, Xeda is the most knowledgeable about that I think. ;)
First you need to understand all the mechanics behind asm though.
-
Hex is basically asm only that you have to look up all the opcodes, though :P
-
Since hex is a less understandable form of ASM, if you can't get around ASM don't expect anything from hex. Hex is really if you don't have a computer but want to do ASM anyway (like Xeda and I did, but I'm definitely stupid compared to Xeda when it comes to hex (and ASM) programming).
-
Also, here's an idea: put the 28 days tutorial aside for a few weeks, and then look at it again.
Eventually you'll get the hang of it ;)
-
Or... Do as the name suggests. :P One day, one lesson. Even though I read it much quicker than that and didn't try any of the examples, I had some pretty strong programming knowledge including Axe and some z80 asm. If you're a total n00b, Hot Dog's tutorial should be around here somewhere (TheCoder1998, that quote is for you :P).
-
Hot Dog's tutorial should be around here somewhere (TheCoder1998, that quote is for you :P).
lol :P
when i got the hang of basic back in the day, i tried hex programming too, but i stopped because i thought it was way too hard
but maybe you'll have more luck than i had :)
-
Also, here's an idea: put the 28 days tutorial aside for a few weeks, and then look at it again.
Eventually you'll get the hang of it ;)
Yep, this is a really good way of doing it. I still learn things every so often when I reread it. I made this (http://www.ticalc.org/archives/files/fileinfo/434/43467.html) chart that is kind of compact, but it has notes about how to use certain types of instructions.
I think the best way to get a handle of how assembly works, you should try to learn integer counting systems like binary, and hexadecimal. It will all make a lot more sense.
-
Hmm, this is a lot information in one go:D Thanks for the quick replies, I will try something...
-
Note: Hex is not a different programming language than Z80 assembly. It's just a different way to display stuff. You can display your posts in hex, you can display code in hex, you can display image data in hex. Same for binary or base-64. In ASM's case, hexadecimal is just a different way to display the code (instead of english acronyms and syntax you just display it in hexadecimal form). However, ASM is very different than TI-BASIC if you are used to the latter, so good luck. I don't do ASM myself, but if you ask help in the right forum section on Omnimaga (welcome, by the way! :D), people will be happy to help. Also, Hot Dog's tutorial can be handy for visual people to understand certain concepts if used with ASM in 28 days, because it provides more visual examples.
-
Where can I find Hot Dog's tutorial?
I already read asm in 28 days but I don't get everything...
-
I have learned to program in assembly on the computer first using mostly ASM in 28 days and an assembler, which was probably a lot easier than learning to program directly in hex. When I wanted to program it without carrying my laptop around with me, I learned to program in hex on the calculator, and I used Deep Thought's opcode table (http://Deep Thought's table) as a reference for the opcodes. Calcsys (http://Calcsys)is also an incredibly useful on-calc program for disassembling your program and looking at other people's programs closely. WikiTI (http://WikiTI) is also a good resource.
-
Yeah, starting directly with hex should be done when you have no other choices.
Even machines don't really understand hex when you think about it.
human symbolic language <> xeda native language <> machine language
-
LOL at the Xeda's native language thing. XD I think she's the only one to have started with hex actually.
-
I'm not sure, but the very first guyz who started to program machines must have done it using hex editing, always comparing what they typed to a book referencing matches with the different available instructions.
Programming in hex today is the greatest possible homage to those dudes...
-
I mean, she's the only one to have done it on the TI calcs.
Also yeah, the first machine was surely programmed by hand. Or maybe they made a maskrom or something to have initial boot.
-
I mean, she's the only one to have done it on the TI calcs.
No. I too.
-
You learnt hex before mnemonics ? Nice. :D
-
Maybe I can learn hex though? I not always have acess to my computer and would like to program without it:)
-
You can. But was still recommend that you learn to code with mnemonics first.
-
Maybe I can learn hex though? I not always have acess to my computer and would like to program without it:)
You can write assembly programs on-calc with Mimas (http://www.ticalc.org/archives/files/fileinfo/431/43140.html). It's an amazing on-calc assembly editor that supports most of the important things any computer-side assembler does.
-
If he wants to use that with Axe then it's a slightly less viable way to do it. There's the hassle of extracting the hex etc...
-
Oh yeah, I remember mimas, but sadly I don't know any assembly :P
I wish I did though
-
One more question to Hex programmers. I searched at TI-Basic developer and once found a Asm Codes List which had a few neat opcodes I still use. Now my problem is: The Program ExecAns which copies the String in Ans to prgmU and runs it, makes a Stop before running it... But I need a return:/ Can anybody help please?
-
What do you mean? In assembly, ret ($C9) just jumps to the last address on the stack. If you have nothing on the stack (just what was on there from the OS when it ran your program) then it will return execution to the OS. Otherwise it will return from a call or to whatever you've put on the stack. You should really just learn the mnemonics which will help you with the basics of assembly. If you want to program oncalc, use Mimas or ASMDREAM.
-
Did you see the program I mean?
http://tibasicdev.wikidot.com/hexcodes
-
Yeah. It's in hex codes. It'd be easier to help if you wrote them out in assembly mnemonics. The last line is a C9, the hex for "ret". But i don't know what you mean by "return" and not "stop". In assembly that's the same thing, quitting the program just means that there was nothing left on the stack. Do you understand what that program does?
-
I'm making a texteditor in Basic. It will store its information in list which are named like the dokuments which have custom names. I use
:Text(-1,1,1,"Creating Document...
:"Matr>List(|F|,L"+Str0 ;Input for the program
:Asm(prgmEXECANS ;Creates a program with this Input
:prgmU ;execution of created program
:|U ;Input for next line
:Asm(DELVAR ;another asm from this site, deletes created program
Now I created a list called like the file. I'll use a simmilar way to edit this list.
If there is another way, please show me but if not please help me return to the main program because it just quits everything...
-
But i don't know what you mean by "return" and not "stop".
I mean the TI-Basic Stop. It just stops all programs and returns to the operating system but I need exactly what you ment with "stack". It should go back one step in this stack but not delete it.
-
ExecAns shouldn't create a program, it runs a program. It takes the code in Ans, puts it into prgmU, and runs prgmU. The problem might be that the current running program (the one that calls prgmEXECANS) gets overwritten when prgmU gets run. I'm not sure, i'll look at it later.
But this isn't really about writing assembly in hex anymore, you might want to open a new thread asking for help on this specific program. But it would really help if you provided the mnemonics instead of the hex so people other than Xeda and perhaps calc84maniac actually knew what the code did. Hex is such a pain.
;(saferam1 = saveSScreen)
name_str = saferam1
size = saferam1+2
code_start = saferam1+4
start:
bcall(_RclAns) ;set pointer into OP1
cp 4
ret nz
ld hl,$55 ;ASCII for 'U'
ld (name_str),hl ;save zero terminated string name
ld (OP1+1),hl
ld hl,code_start
ex de,hl ;de = code_start, hl = ans ptr?
ld c,(hl) ;i assume bc = size of Ans
inc hl
ld b,(hl)
inc hl
ld (size),bc
ldir ;copy code in Ans into saferam
bcall(_ChkFindSym)
jr c,not_found
bcall(_DelVarArc) ;del prgmU if it existed
not_found:
ld a,5 ;5 = non-protected program
ld hl,saferam1
bcall(_ExecuteNewPrgm) ;a = var type, hl = pointer to structure (zero terminated string, size (word), program data)
ret
A couple things: i'm not sure if RclAns actually gives readable results in a/de/hl. They seem to assume that _RclAns puts out the same outputs as _ChkFindSym (see WikiTI (http://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:42F1)). WikiTI and the 83 Plus System Routines manual both say all registers are destroyed (ie. return junk/non-useful info). I don't know what happens with _ExecNewPrgm, it may kick the currently running BASIC program out.
EDIT: If all you want to do is create a program, you should look at the _CreateProg (http://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:4339) bcall.
-
Was that to me? I don't understand ASM... But by the way I want to learn it though.
-
That's the same code as from TI-BasicDev just in assembly mnemonics. I'm not really sure what you want, when you run that program does it return to the TI-OS? Like i said there, there's another routine to call if all you want to do is create a program (_CreateProg).
-
Was that to me? I don't understand ASM... But by the way I want to learn it though.
Wait. Did you even follow what we said ? Hex programming = assembly. You can't learn one separately, it's just two ways to write it.
-
Sorry, I am bad at explaining... I know HEX and ASM are the same things, the first one is just ASM translated to the calculator's language.
Or am I wrong?!
-
That is correct. Streetwalrus was referring to this:
Was that to me? I don't understand ASM... But by the way I want to learn it though.
We are giving you the ASM to help you learn it. You can't really understand the hexadecimal machine code without understanding the ASM instructions with which they are associated.
-
So I am trying again to learn ASM in 28 days (it's a lot easier the second time) but TASM does not work on my new 64 bit notebook. I downloaded SPASM but now even the copy-pasted hello world program makes it throw errors on each b_call and I really don't know what went wrong... I suppose the TASM syntax is a bit different from the SPASM syntax?
-
You'll need to add:
#define b_call(xxxx) rst 28h \ .dw xxxx
..to the top. Also, i would recommend using this ti83plus.inc (http://brandonw.net/svn/calcstuff/OS2/trunk/extras/ti83plus.inc) instead. Most people use bcall(_XXXX), you might find that that is already defined in your ti83plus.inc.
EDIT: Just to clarify, that is bcall without the underscore. I believe TI added an instruction for B_CALL, so you might be able to use B_CALL _NewLine (no parentheses) just like any other instruction, too.
-
Ok, thank you, I'll try this when I'll have more time... (If I ever will have more time... :P :/)
-
It does not work...
-
What doesn't work? Assembling it? Are you using the ti83plus.inc (http://brandonw.net/svn/calcstuff/OS2/trunk/extras/ti83plus.inc) that i linked to? What exactly are you trying to assemble (can you post the code)? Does it not assemble or does the .8xp not work?
-
What does not work is the assembling.
I use the include file you showed me.
Code:
.nolist
#include "ti83plus.inc"
#define ProgStart $9D95
.list
.org ProgStart - 2
.db t2ByteTok, tAsmCmp
b_call(ClrLCDFull)
ld hl, 0
ld (PenCol), hl
ld hl, msg
b_call(PutS)
b_call(NewLine)
ret
msg:
.db "Hello world!", 0
.end
.end
I removed the underscores before the b-call names, like you said me
-
The underscores need to be in there afaik.
-
It once didn't work with underscores :blah:
-
I was talking about the underscore in the B_CALL macro ;)
-
Wait, let me see if I understand correct.
A b_call calls a subprogram which is stored in the Include file. So, for example,you don't have to set each pixel to make an "A" or "B". You say: Output this letter here! While assembling later, SPASM searches in the include file for this letter and exchanges the "Output this letter here" with "Set these pixels". Right?
-
Not quite. A bcall is like a subroutine, except it's provided by the OS.
-
The bcalls are a bit more complicated than that. What you will find in ti83plus.inc is an address for the bcalls. Someone else can probably explain this much better, but i believe essentially there's a big table which holds the address + flash page of the bcalls. The bcalls are stored in the OS, the include file just provides you with an easy way to access them. Rather than remember the address in the table (for example, $450A for _PutS) you can just type the name. There isn't any code in the include file so it won't increase the size of your file any, there are only equates.
-
The bcalls are a bit more complicated than that. What you will find in ti83plus.inc is an address for the bcalls. Someone else can probably explain this much better, but i believe essentially there's a big table which holds the address + flash page of the bcalls. The bcalls are stored in the OS, the include file just provides you with an easy way to access them. Rather than remember the address in the table (for example, $450A for _PutS) you can just type the name. There isn't any code in the include file so it won't increase the size of your file any, there are only equates.
I can confirm that bcalls use a vector table.
-
Ah, OK. Thank all you!
-
Let me see...
So are there good tutorials except of 28 days and Hotdog's?
And where do I find Hotdog's tutorial?
I'm sorry for my whole questions, ASM is just a trouble :/
-
The only tutorial I ever used besides ASM in 28 days and the other existing ones when I tried learning ASM was ASMGuru, but the learning order is weird and it's only for the TI-83, not the 83+, so it might confuse you even more when you switch back to the 83+.
-
I highly recommend CoBB's z80 guide:
http://sgate.emt.bme.hu/patai/publications/z80guide/ (http://sgate.emt.bme.hu/patai/publications/z80guide/)
I started with AsmGuru back in the day and thought it was great, but really all it teaches you is how to use bcalls and work with system flags. Not too useful if you want to get started on games as you won't really understand the logic behind things. CoBB's tutorial provides a more theoretical approach i think as does 28 Days and will get you much closer to being able to dive into your own games.
I never spent too much time looking through Hot_dog's tutorial, it came a bit after my tutorial time, but it's in the Omnimaga archives:
http://www.omnimaga.org/files/Our-TI-PC-Products-Music-and-Calculator-Videos/Our-TI-Documentations/ (http://www.omnimaga.org/files/Our-TI-PC-Products-Music-and-Calculator-Videos/Our-TI-Documentations/)
EDIT: You might want to check out the "readme" to CoBB's tutorial, it's got a nice explanation of the dangers of just using other people's code (or BCALLs) without really understanding/taking the time to understand what they do:
http://sgate.emt.bme.hu/patai/publications/z80guide/read1st.html
-
Hot_Dog's tutorial is more for people who are visual and cannot learn without concrete examples that are interesting to them or real life analogies. IIRC he said it was meant to be used alongside ASM in 28 days.
-
Thank you (both).
I think in about a year the NikProgrammer TM will open it's assembly factory and start produce software :blah: :D :-\
-
The best thing you can do in my opinion is start with a couple small projects and gradually go from there. Really once you get the concept of spriting and tilemapping down there's a whole lot you can do. And of course ask lots of questions. Smaller projects are much more encouraging as you will actually finish them, most (but definitely not all) larger projects remain unfinished or, as was the case with The Verdante Forest, end up burning you out and making you leave the community once the project is actually finished ;) Off topic a bit, i really wish Maarten/Kozak had released the source, i would've liked to try fixing the huge lag when there are lots of animations on screen.