Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 & ez80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 & ez80 Assembly
Author Message
Tabarnaco


Newbie


Joined: 04 Feb 2011
Posts: 9

Posted: 04 Feb 2011 07:16:02 pm    Post subject:

Probably a stupid question but with next to no documentation, it's hard to do anything when you don't know anything.
So I used Notepad when I first tried to program in Z80 Assembly but it's obviously pretty bad, with no syntax highlighting or the easily accessible features that IDEs offer. I downloaded Latenite and just copying and pasting a Hello World program doesn't work, because ti83plus.inc isn't included, and when I download it from TI's site it gives me a bunch of errors:

Code:
Brass Z80 Assembler 1.0.4.1 - Ben Ryves 2005-2006
-------------------------------------------------
Assembling...
Error: Instruction '2' not understood. [ti83plus.inc:29]
Error: Could not create new label 'EQU' (previously defined?) [ti83plus.inc:30]
Error: Instruction '3' not understood. [ti83plus.inc:30]
Error: Could not create new label 'EQU' (previously defined?) [ti83plus.inc:31]
Error: Instruction '0ah' not understood. [ti83plus.inc:31]

And so on and so forth.

What do.


Last edited by Guest on 04 Feb 2011 07:16:44 pm; edited 1 time in total
Back to top
Sven.Thomas0


Active Member


Joined: 19 May 2009
Posts: 520

Posted: 04 Feb 2011 08:05:15 pm    Post subject:

I've only ever used TASM, but I don't use mnemonics. Nevertheless, here is what I use...

I add this to the start of the .inc file:


Code:
#define equ .equ
#define EQU .equ
#define end .end
#define END .end
#define header      .dw $6DBB
rBR_CALL      equ 28h
BRT_JUMP0      equ 50h
#define bcall(xxxx) .db $EF \ .dw xxxx
#define bjump(xxxx) call 50h \ .dw xxxx

And to the actual program I think you put this at the beginning:

Code:
.nolist
#include "ti83plus.inc"
.list
.org    $9D93
 .dw $6DBB


Again, don't really use assemblers and the only one I have experience with is TASM.
Back to top
Tabarnaco


Newbie


Joined: 04 Feb 2011
Posts: 9

Posted: 04 Feb 2011 10:15:47 pm    Post subject:

Nevermind, I'm an idiot, I took the include file from TI's website when I should've downloaded a special one compatible with TASM.

I got a warning while assembling though, data overlap between $13B26 and $13B27.

Code:
; ===============================================================
; Hello World
; ===============================================================

.nolist
   #include "ti83plus.inc"
.list
.org $9D95 - 2
   .db t2ByteTok, tAsmCmp

Main:
   b_call(_ClrLCDFull);
   b_call(_HomeUp);
   ld hl,Hello;
   b_call(_PutS);
   ret

Hello:
   .db "Hello, world.",0
.end
.end


I even tried commenting out almost all of the lines and the error persisted.


Last edited by Guest on 05 Feb 2011 12:11:37 am; edited 1 time in total
Back to top
Sven.Thomas0


Active Member


Joined: 19 May 2009
Posts: 520

Posted: 04 Feb 2011 10:20:21 pm    Post subject:

Ah, well at least the problem is solved ^-^
Also, there are other .inc files designed for compatibility with TASM... They include some undocumented bcalls and stuff...
Back to top
Tabarnaco


Newbie


Joined: 04 Feb 2011
Posts: 9

Posted: 05 Feb 2011 12:45:50 am    Post subject:

I commented out ".org $9D95 - 2" and the warning went away...
I can't leave it like that though can I? There's something wrong there. Apparently it works fine if I change it to .org $9D95 or higher, but anything under that causes the warning to be displayed, with different memory addresses naturally.

Also, I'm using Brass 2 (I think) with Latenite. I tried to update it because on its creator's website there was a screenshot of him using Brass 3 with it as far as I'm aware. But it just crashes when I try to compile something when I do that.


Last edited by Guest on 05 Feb 2011 12:55:29 am; edited 1 time in total
Back to top
Sven.Thomas0


Active Member


Joined: 19 May 2009
Posts: 520

Posted: 05 Feb 2011 01:12:08 am    Post subject:

Maybe you could use 9D93h?
Back to top
Tabarnaco


Newbie


Joined: 04 Feb 2011
Posts: 9

Posted: 05 Feb 2011 03:52:49 pm    Post subject:

No difference, data overlap.
I tried to emulate it but it doesn't seem to be compatible with my TI-84+ SE ROM...
Back to top
Sven.Thomas0


Active Member


Joined: 19 May 2009
Posts: 520

Posted: 05 Feb 2011 03:55:51 pm    Post subject:

You may need to define ".org" as "org"
Again, I am not sure, I just try things until I get results Very Happy
Back to top
Madskillz


Active Member


Joined: 02 Jan 2004
Posts: 608

Posted: 05 Feb 2011 05:26:59 pm    Post subject:

He shouldnt need to define org. His header looks right.

I mean I use 9D93 too, let me run it with spasm.

Well I got yours to work, but I really didn't do anything to it. I tried they way I normally write my header and then yours and nothing changed. One thing I noticed is that you put a semi-colon after every line. I dont know if that was a latenight/Brass thing but they are used for comments in assembly so you don't need them unless you're going to write a comment. You also don't need the homeup bcall.


Code:
   .nolist
        #include "ti83plus.inc"
   .list
   .org $9D93
         .db t2ByteTok, tAsmCmp
       
   b_call(_ClrLCDFull)
       ld      hl, hello
        b_call(_PutS)
        ret

hello:
        .db "Hello, world!", 0
.end
.end


Last edited by Guest on 05 Feb 2011 06:12:00 pm; edited 1 time in total
Back to top
Sven.Thomas0


Active Member


Joined: 19 May 2009
Posts: 520

Posted: 05 Feb 2011 06:05:42 pm    Post subject:

Ah, okay. Yeah, the .org thing works with TASM, I know that, but I wasn't sure.
Back to top
Impiety


Newbie


Joined: 06 Feb 2011
Posts: 5

Posted: 06 Feb 2011 12:51:47 am    Post subject:

If you're using Latenite/Brass, you don't have to add the .org and .db t2ByteTok, tAsmCmp stuff to your program because Latenite already does it for you. Brass doesn't compile the main Program.asm file - it compiles a file called Headers.asm (located in the Includes folder) which in turn assembles Program.asm, adding the necessary .org and .db commands to the header of the program.
Back to top
Madskillz


Active Member


Joined: 02 Jan 2004
Posts: 608

Posted: 06 Feb 2011 01:21:48 am    Post subject:

Ah there you go, I didn't know Brass/Latenite did that. If your looking for an IDE to use, I suggest WabbitCode, you can find it over at www.revsoft.org in the forums. The windows version is updated more, but there is a Mac version as well.
Back to top
Tabarnaco


Newbie


Joined: 04 Feb 2011
Posts: 9

Posted: 06 Feb 2011 01:30:09 am    Post subject:

Madskillz wrote:

Well I got yours to work, but I really didn't do anything to it. I tried they way I normally write my header and then yours and nothing changed. One thing I noticed is that you put a semi-colon after every line. I dont know if that was a latenight/Brass thing but they are used for comments in assembly so you don't need them unless you're going to write a comment. You also don't need the homeup bcall.

I just copied the whole thing from Wikipedia after the 28 Days one didn't work, and forgot to remove them.
Not sure what HomeUp does exactly.


Impiety wrote:
If you're using Latenite/Brass, you don't have to add the .org and .db t2ByteTok, tAsmCmp stuff to your program because Latenite already does it for you. Brass doesn't compile the main Program.asm file - it compiles a file called Headers.asm (located in the Includes folder) which in turn assembles Program.asm, adding the necessary .org and .db commands to the header of the program.

thx brah


Madskillz wrote:

Ah there you go, I didn't know Brass/Latenite did that. If your looking for an IDE to use, I suggest WabbitCode, you can find it over at www.revsoft.org in the forums. The windows version is updated more, but there is a Mac version as well.

I can only find the Mac versions, and "Beta 1" for Windows.
Well, it seems to have an auto-updater anyway, so it's fine.
Though it seems to think that there's always a new version, or doesn't verify whether the current one is the latest.


Uh, it doesn't seem usable at all, I created a new project, the main .asm file wasn't created, it wanted to delete it, I clicked on the New icon, it crashed, I restarted, clicked on the New icon, it crashed, restarted, did it again, it worked, tried to open my project, and it crashed. Please tell me I'm using the wrong version, otherwise I think I'll stick with Latenite. I prefer its UI anyway, even if it is outdated.


Used WabbitEmu to test the compile program. Tweaked it slightly, this seems to work.

Code:
; ===============================================================
; Hello World
; ===============================================================

.nolist
   #include "ti83plus.inc"
.list

Main:
   b_call(_ClrLCDFull)
   b_call(_HomeUp)
   ld hl,Hello
   b_call(_PutS)
   b_call(_NewLine)
   ret

Hello:
   .db "Hello, world.",0
.end
.end

Without HomeUp it is displayed on the second line.


Last edited by Guest on 06 Feb 2011 01:53:55 am; edited 1 time in total
Back to top
Sven.Thomas0


Active Member


Joined: 19 May 2009
Posts: 520

Posted: 06 Feb 2011 01:58:56 am    Post subject:

Ah, homeup just sets the cursor position to the upper left hand corner. It is the same as 210000224B84 or:
ld hl,0
ld (844Bh),hl

844Bh is the address in RAM for the cursor
Back to top
Madskillz


Active Member


Joined: 02 Jan 2004
Posts: 608

Posted: 06 Feb 2011 12:53:02 pm    Post subject:

I know the windows version, Buckeye/Spencer are constantly updating it with fixes. I know wabbitemu is often updated here: http://wabbit.codeplex.com/ first. The Mac version can be iffy. If you have any questions/problems feel free to post at RevSoft. Buckeye will respond pretty quick. I will try and answer any problems you got here.

You could ld (curCol) and/or (curRow) with a specif number to move the text any place you want on the homescreen. I meant that you didn't need HomeUp to display text. That 844Bh is curRow, that is what ThunderBolt was talking about. I think 844Ch is curCol's.
Back to top
Sven.Thomas0


Active Member


Joined: 19 May 2009
Posts: 520

Posted: 06 Feb 2011 02:17:51 pm    Post subject:

Yeah those are the addresses (thanks ^-^). Pretty much, CurRow is 0 to 7 and CurCol is 0 to 15. So to set both:


Code:
ld hl, Col*256+Row      ;Col is a number and Row is a number
ld (CurRow),hl
Back to top
Tabarnaco


Newbie


Joined: 04 Feb 2011
Posts: 9

Posted: 06 Feb 2011 04:39:55 pm    Post subject:

What if I want to display a number on the screen? Because the 28 days tutorial thing is going on about stacks, arrays and calculations but if I can't try things out myself I can't really understand it.
Back to top
Sven.Thomas0


Active Member


Joined: 19 May 2009
Posts: 520

Posted: 06 Feb 2011 05:08:38 pm    Post subject:

I like to use EF0745 which I believe is bcall(_DispHL). All it does is display the decimal value of HL. So if you did:

Code:

 ld h,0
 ld l,a
 bcall(_DispHL)

This would display the value of register A.


Last edited by Guest on 06 Feb 2011 05:08:53 pm; edited 1 time in total
Back to top
Tabarnaco


Newbie


Joined: 04 Feb 2011
Posts: 9

Posted: 07 Feb 2011 02:02:01 pm    Post subject:

Okay, thanks, now I tried to do some calculations and am having trouble performing substractions.


Code:
ld hl,500
ld a,100
ld d,0
ld e,a
sbc hl,de
bcall(_DispHL)
bcall(_NewLine)

I know that zero-extending a works since I substituted de for hl and it displayed 100 as it should.
But I assume there's a problem with sbc hl,de because the number displayed is 33816.
What's wrong with it?

I also added sub 50, ld h,0 then ld l,a right after it and it returned 254, I had to reload 100 into a to make it work. Why does it change spontaneously?

Okay, I loaded 500 into hl again because it seems to reset itself or something after a bcall(_DispHL) or (_NewLine), not sure which. Now it displays 399 even though it's supposed to be substracted by a hundred... I added dec a after setting it to 100 and now it displays 400 properly, but that's still mathematically incorrect. Any reason why this is happening?

Also, I have a condition that displays something if A is equal to 100 and another if it is not, and when the program finishes executing "Done" is displayed after the numbers, on the same line as the text but on the right, and the blinking cursor overwrites the first letter of it. I tried seting CurRow to a different value but it doesn't work, bcall(_NewLine) doesn't do anything either.


Last edited by Guest on 07 Feb 2011 02:38:07 pm; edited 1 time in total
Back to top
Impiety


Newbie


Joined: 06 Feb 2011
Posts: 5

Posted: 07 Feb 2011 06:35:51 pm    Post subject:

The instruction sbc subtracts the operand as well as the value of the carry flag from HL. So if you're trying to do sbc HL, DE, the calculator will actually perform the calculation: HL - (DE + carry_flag). In your particular case, the carry flag happened to be 1, which explains why you got 399 instead of 400.

If you want to circumvent this problem, just add:

scf
ccf

...right before you do sbc. It should effectively zero out the carry flag. So, your code should look like:


Code:
ld hl,500
ld a,100
ld d,0
ld e,a
scf
ccf
sbc hl,de
bcall(_DispHL)
bcall(_NewLine)


Hope I helped Smile
Back to top
Display posts from previous:   
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  Next
» View previous topic :: View next topic  
Page 1 of 2 » All times are GMT - 5 Hours

 

Advertisement