Hello! I have recently gotten into Z80 Assembly programming, and of course, I started with the Hello World program. I am programming using Spasm and a 64-bit Windows 8.1 for a TI-84 Plus C Silver Edition. Please, please, I beg of you, do not ask me what software or hardware I am using. I just told you.

Anyway, here is my
Code:
.nolist
   #include "ti84pcse.inc"
   
.list
   .org UserMem - 2
   .db tExtTok, tAsm84CCmp
   
   bcall(_ClrLCDFull)
   bcall(_HomeUp)
   ld hl, msg
   bcall(_PutS)
   bcall(_NewLine)
   
   ret
   
msg:
   .db "Hello, world!", 0


It compiles properly, but when I run it on jsTIfied, it goes until the

Code:
   bcall(_NewLine)


It ignores this line of code and ends the program. That is to say, the dotted line appears directly below the "Hello, world!" without a space below, like in a TI-BASIC program. In other words, the "Done" appears on the same line as the "Hello, world!" I would include an image, but I don't know how to do so, so if someone could tell me how to include an image, I'd be grateful.

Can anyone who has had a similar problem, or who knows what is happening, please help me?
I too have encountered similar problems for a while, I have my own ASM Assistance Topic that may contain some useful information for you. To include an image, use an emulator and the rest should be simple. Take the recorded file and upload it to an image sharing site like imgur and add the link like you would an image with [image] and [/image]
Here is the screenshot:


Here's how I want it to look:


The latter image was done with TI-BASIC; that's the whole point, I want to be able to do that in Z80 Assembly, but I cannot get _NewLine to work.

APotato, how do I get to your ASM assistance topic?
Here: http://www.cemetech.net/forum/viewtopic.php?t=10595
it looks like we have different problems, quite interesting, I will try to get mine to work and maybe we can help each other through this learning process? Smile
Does this happen if you put in two NewLine Bcalls? Try it out and see what happens... Of course, you could always change the data in currow and curcol to what ever you would like. Smile
Yeah, _NewLine is essentially:

Code:
ld hl,CurRow
inc (hl)   ;increase CurRow by one
inc hl
ld (hl),0   ;set CurCol to 0
For this you probably just need to increase CurRow, since i doubt the _DispDone or whatever the bcall is even looks at CurCol.

EDIT: Another option for debugging might be this:

Code:
ld hl,(CurRow)
ld h,0
bcall(_DispHL)
...before and after the _NewLine bcall, to see what value CurRow has. And just asking, but the assembler doesn't complain about anything when you compile, does it? I dunno if jsTIfied has a debugger or not, if it does it might be worthwhile tracing it and seeing what the value of CurRow is before and after the _NewLine bcall. TiLem2 also has CSE support and i assume a debugger, too (the non-CSE calcs do). I don't have a CSE so can't say.

EDIT2: And have you tried running it on a real calc?
Turn off MathPrint.
KermMartian wrote:
Turn off MathPrint.


That works too. Smile
When I tried two _NewLine bcalls, nothing changed.

When I substituted
Code:
   ld hl, CurRow
   inc (hl)
   inc hl
   ld (hl), 0
for the _NewLine bcall, nothing changed.

I have not tried running any Z80 Assembly program on my real calculator, because I do not want to risk permanently damaging it until I am much more experienced in Assembly programming.

KermMartian, your suggestion worked perfectly. Once I changed to CLASSIC mode, _NewLine made a difference. However, is there a way to accomplish this without changing to CLASSIC mode?
If not, what is the Assembly code to change that specific flag? I cannot find the address in ti84pcse.inc. I would like to change the mode to CLASSIC at the beginning and change it back to MATHPRINT at the end.
In addition, why does _NewLine only work in CLASSIC mode? Why, even in CLASSIC mode, is a _NewLine required, unlike in a TI-BASIC program, in which the "Done" appears on a new line, automatically? Is this a bug/flaw in TI-OS?

Chickendude, are you sure that TilEm2 has TI-84 Plus C Silver Edition support? I looked at their website, and it seems as though they don't.
If they don't, does anyone know of any good, free, offline emulators? WabbitEmu, by far the best, used to work for me, but it no longer does.
I think Mathprint is set by a flag. Try this:


Code:
res 5,(iy+44h)


Or maybe:


Code:
set 5,(iy+44h)


According to BrandonW's website, you should clear the screen as well as fill CmdShadow and TextShadow 20h's if you change this flag. Wabbit supports CSE...
Rather than set the flag automatically at the end, i would save it and restore it. That way you won't turn MathPrint on if the user had originally turned it off. You can save it a couple of ways, you can put it on the stack, you can save it inside your program, or you can save it into saferam. I'm not familiar with saferam areas on the 84+ CSE so someone else will have to give you that location. Here are some examples:
Using the stack:

Code:
    ld a,(iy+$44)
    push af
;... rest of program
    pop af
    ld (iy+$44),a

Saving it into your program:

Code:
    ld a,(iy+$44)
    ld (saveMP),a
;...rest of program
    ld a,(saveMP)
    ld (iy+$44),a
saveMP:
.db 0

Or a slightly more optimized way, using SMC (self-modifying code):

Code:
    ld a,(iy+$44)
    ld (saveMP),a
;...rest of program
saveMP = $+3   ;this will change the 0 in "ld (iy+$44),0" to whatever is at (iy+$44)
    ld (iy+$44),0
You could also save just the one bit, but i don't think you'll be changing any of the other flags stored in the byte at (iy+$44), so it's probably not worth the trouble. But to give you some practice with the bit instructions:

Code:
    ld a,(iy+$44)
    and %00100000  ;this turns every bit except bit 5 to a zero, bit 5 will be whatever the MathPrint flag is (on = 1, off = 0)
    push af
;...
    pop af
    or (iy+$44)     ;assuming you set bit 5 to zero (turned off mathprint) you can just OR it with the old MathPrint bit
    ld (iy+$44),a

Hopefully i haven't confused things too much for you, if you've got any questions ask away and i'm glad to hear you finally got your first program working Smile

Also, it's really seriously very hard to permanently ruin your calculator without actually trying to do so (and having a lot of knowledge about how the calculator itself works). All that will likely happen is that your RAM will reset. You don't even have to worry about those blue lines ruining your LCD on the CSE Razz

EDIT: And yeah, TilEm2 has CSE support, but i don't think the latest Windows installer includes it, you may have to compile it yourself from the latest source in the sourceforge repository.
Can someone please tell me what is wrong with this program?

Code:
.nolist
   #include "ti84pcse.inc"
   
.list
   .org UserMem - 2
   .db tExtTok, tAsm84CCmp
   
   ld a, (iy+$44)      ;change to CLASSIC
   push af
   res 5, (iy+$44)
   
   bcall(_ClrLCDFull)      ;display message
   bcall(_HomeUp)
   ld hl, str1
   bcall(_PutS)
   bcall(_NewLine)
   
   pop af         ;restore original mode
   ld (iy+$44), a
   
   ret            ;end
   
str1:
   .db "Hello, world!", 0   ;message

As you can see, I hope, the program is supposed to change to CLASSIC mode, display the message, and go back to the original mode. However, it seems to display the text in MATHPRINT mode, when I run it on jsTIfied.

WabbitEmu has CSE support, I know. However, it does not work on my computer. Let's not get into that now.
In addition, everyone keeps saying that TilEm2 has CSE support. I cannot find this. Can someone point me in the right direction?
Try seeing if what happens if you put

Code:
ld a, (iy+$44)      ;change to CLASSIC
push af
res 5, (iy+$44)


after the bcall Homeup. Not sure if this will work yet, but it can't hurt. Smile
This doesn't work either.

Code:
.nolist
   #include "ti84pcse.inc"
   
.list
   .org UserMem - 2
   .db tExtTok, tAsm84CCmp
     
   bcall(_ClrLCDFull)      ;clear screen
   bcall(_HomeUp)
   
   ld a, (iy+$44)      ;CLASSIC mode
   push af
   res 5, (iy+$44)
   
   ld hl, str1         ;display message
   bcall(_PutS)
   bcall(_NewLine)
   
   pop af         ;restore original mode
   ld (iy+$44), a
   
   ret            ;end program
   
str1:
   .db "Hello, world!", 0   ;message

It is quite amazing that a Hello World program can be this difficult to program correctly.

When I have time, I shall try methods other than the stack to store user settings. However, I cannot see why storing to the stack does not work.

Two things: can someone tell me why pushing to the stack doesn't work? And can someone please explicitly give me a link to an offline non-WabbitEmu emulator with CSE support?
Are we able to double check that flag equate?

Also here is wabbitemu fork thread by geekboy: http://www.cemetech.net/forum/viewtopic.php?t=10729
Yes, (iy+$44) is the flag for MATHPRINT (1=on, 0=off). When I remove the segment of code that restores the original mode, the calculator is in CLASSIC mode, although it is worth mentioning that weird stuff shows up on the screen. I am not sure if this is the fault of jsTIfied or my code. I will post a screenshot of this "weird stuff" at a later time.

Are there really no offline emulators other than WabbitEmu, which doesn't work on my computer, and TilEm2, to which no one will give me the link for CSE?
WHY DOESN'T THIS WORK?!?!?!?!?!?

Code:
.nolist
   #include "ti84pcse.inc"
   
.list
   .org UserMem-2
   .db tExtTok,tAsm84CCmp
   
   ld a,(iy+$44)      ;save original mode
   ld (saveMP),a
   
   res 5,(iy+$44)      ;CLASSIC mode
   
   bcall(_ClrLCDFull)      ;display message
   bcall(_HomeUp)
   ld hl,str1
   bcall(_PutS)
   bcall(_NewLine)
   
   ld a,(saveMP)      ;restore original mode
   ld (iy+$44),a
   
   ret            ;end program
   
str1:
   .db "Hello, world!",0   ;message
   
saveMP:
   .db 0

Every force of nature is determined to work against my accomplishing a simple Hello World program in a relatively simple Assembly language.

First, I tried the stack. That didn't work. This is really annoying, even outside of this specific program--the stack is a central part of Assembly, and if I can't even use the stack, I might as well give up Assembly.

Then, I tried the above code, but optimized with SMC. As you can tell from the nature of this post, that didn't work.

After that, I tried the above code. That, somehow, doesn't work!! I cannot figure out what is possibly wrong with it.

As far as I know, storing something in the program, in the stack, and in scrap RAM are the only options for memory storage; but I can't, it seems, store something in the program or in the stack. Scrap RAM is now my only option. This is ridiculous.

Because of the fact that every time someone replies to one of my posts, they only answer about half of my questions, I have a list of my most important requests:

1. Will someone please explain why storing to the stack does not work?

2. Will someone please give me a link to an offline emulator other than WabbitEmu?

3. Will someone please explain what is wrong with the above code?

4. Will someone please explain what is wrong with the SMC version of the above code, suggested by chickendude (see his post in this topic)?
Are you sure the program isn't just switching back to MathPrint when it exits? Try pausing: bcall(_GetKey) before you switch back to the original mode.

1. Storing to the stack does work. It's probably another issue with the program.
2. If you use Linux, you can use TilEm2. The latest version has CSE support, but the Windows binary hasn't been updated to include that. I can ask contra about possibly putting together a Windows binary with CSE support. The CSE is relatively new and came out after the TI heyday of the late 90s/early 00s. All emulators are developed by the community (not by TI) and are done in their spare time.
3. I don't have a CSE so can't test it. I'd say you should try pausing before you switch the flag back or don't switch the flag back before exiting to see what happens. Otherwise the code looks fine. It's generally a good idea to pause before exiting back to the OS anyway.
4. There's nothing wrong with the SMC, it's used correctly and should store the original flag and then load it back. Seeing as it's being drawn in MathPrint mode, it's obvious that the SMC is working. If it weren't working, it'd still be stuck in classic mode when you exited.
I am going back to the stack method. Again, here is my code:
Code:
.nolist
   #include "ti84pcse.inc"
   
.list
   .org UserMem-2
   .db tExtTok,tAsm84CCmp
   
   
   ld a,(iy+$44)      ;find original mode
   push af         ;load original mode
   res 5,(iy+$44)      ;change to CLASSIC mode
   
   bcall(_ClrLCDFull)      ;clear screen
   bcall(_HomeUp)      ;reset display coordinates
   ld hl,str1         ;load message
   bcall(_PutS)         ;display message
   bcall(_NewLine)      ;display new line
   
   pop af         ;unload original mode
   ld (iy+$44),a      ;restore original mode
   
   ret            ;end program
   
str1:
   .db "Hello, world!",0   ;message


MateoConLechuga said:
Quote:
According to BrandonW's website, you should clear the screen as well as fill CmdShadow and TextShadow 20h's if you change this flag.


I know that cmdShadow and textShadow are two locations in RAM, but what is "filling CmdShadow and TextShadow 20h's"? How do I do this? I suspect that my not doing so is the cause of my program's failure.
Have you tried putting a bcall(_GetKey) before the pop af?

Also, since you're resetting the flag back to its original state, i don't think you need to worry about filling CmdShadow and TextShadow. They are two "saferam" places that shells like Ion and maybe MirageOS used to use. You should be able to find their equates in the include file.
  
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 2
» 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