Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: AngelFish on November 14, 2010, 03:23:12 pm

Title: ASM Help
Post by: AngelFish on November 14, 2010, 03:23:12 pm
I was recently experimenting with some ASM code, and as some of you might be aware, I kind of ****ed up Wabbit. It stopped loading apps altogether and programs weren't running correctly. Reinstalling fixed most of the problems, except that wabbit is now really slow. Anyway, I tried some code, and it didn't appear to work, so I'm wondering if this is just wabbit, or me

Would anyone mind looking over this example code?

Code: [Select]
#include "ti83plus.inc"
.org $9d93
.db 0BBh, 06Dh
     ld hl,0
     ld (CurRow),hl
     ld hl,String
     bcall(_PutS)
     bcall(_getkey)
     ret
String:
.db "Hello World",0

From what I understand, this should display "Hello World" and wait for the user to press a key. The problem is that it's not doing that. It's just running through the program.
Title: Re: ASM Help
Post by: calcdude84se on November 14, 2010, 03:34:18 pm
Indeed, it should. Are you using a shell to run the program?
Title: Re: ASM Help
Post by: AngelFish on November 14, 2010, 03:42:12 pm
No, I'm running it with the Asm( tag from the homescreen.
Title: Re: ASM Help
Post by: calcdude84se on November 14, 2010, 04:09:41 pm
It works perfectly fine for me O_o.
Title: Re: ASM Help
Post by: AngelFish on November 14, 2010, 04:15:01 pm
Would you mind trying the compiled file?
Title: Re: ASM Help
Post by: calcdude84se on November 14, 2010, 04:18:58 pm
Sending now :)
Title: Re: ASM Help
Post by: AngelFish on November 14, 2010, 04:20:04 pm
Thanks :)

You don't have to use your physical calculator though. I wouldn't want my code to break something.
Title: Re: ASM Help
Post by: calcdude84se on November 14, 2010, 04:22:02 pm
The file disassembles to
Code: [Select]
ld hl,0
ld ($0000),hl
ld hl,string
ret
string:
.db "Hello World",0
O_o
Edit: I sent it to my physical calc because I have Calcsys there ;)
Title: Re: ASM Help
Post by: AngelFish on November 14, 2010, 04:26:42 pm
That's really odd.

I've checked the Batch file and the source I posted is the entire example code. I can't seem to find any reason for it to ignore the bcalls.

EDIT: Bcalls are included in the 83plus.inc file, right?
Title: Re: ASM Help
Post by: calcdude84se on November 14, 2010, 04:28:37 pm
They indeed are :)
What are you using to assemble it? What does it say?
Title: Re: ASM Help
Post by: AngelFish on November 14, 2010, 04:31:21 pm
I'm using SPASM. It hasn't given me any feedback thus far.
Title: Re: ASM Help
Post by: calcdude84se on November 14, 2010, 04:34:37 pm
That's strange. What's especially disconcerting is that it changed curRow to a 0 and eliminated both bcall's entirely.
Could you try replacing each bcall(xxxx) with "rst 28h \ .dw xxxx", where xxxx is the name of the routine bcalled?
If you could disassemble it yourself, that would be helpful too :)
Title: Re: ASM Help
Post by: AngelFish on November 14, 2010, 04:58:39 pm
Replacing the commands throws the calculator into an infinite loop.  :(

By the way, the disassembled program is this:

Code: [Select]
LD B, 21
LD BC, 9D00
or L
NOP
NOP
DEC B
Inc HL
LD BC, 9D00
...

I know that can't be the proper code, but that's what location the VAT lists the program at. Before that location are a few dozen NOPs and after it the code repeats.
Title: Re: ASM Help
Post by: Deep Toaster on November 14, 2010, 05:01:56 pm
That's really odd.

I've checked the Batch file and the source I posted is the entire example code. I can't seem to find any reason for it to ignore the bcalls.

EDIT: Bcalls are included in the 83plus.inc file, right?

It's also ignoring the CurCol load...

Does Spasm give you any errors? Maybe the names weren't defined.
Title: Re: ASM Help
Post by: AngelFish on November 14, 2010, 05:29:02 pm
Nope. SPASM executes without returning any errors.
Title: Re: ASM Help
Post by: Hot_Dog on November 14, 2010, 05:32:26 pm
Are you, by any chance, running this on a Ti-84+ with OS 2.53? Make sure it's on classic mode if so
Title: Re: ASM Help
Post by: AngelFish on November 14, 2010, 05:37:16 pm
As much as I'd like to blame OS v 2.53 for this, switching the mode doesn't do anything.
Title: Re: ASM Help
Post by: DrDnar on November 14, 2010, 05:50:11 pm
Are you sure you're including ti83plus.inc? SPASM likes to pretend that it's correctly assembled a program, when in fact, it has actually replaced any bad opcodes or labels with 0. This is bad if you have jp badLabel.
Title: Re: ASM Help
Post by: AngelFish on November 14, 2010, 05:56:57 pm
You can check the source from the previous page. I included the file and I'm pretty sure I have the correct file, seeing as how I'm using the official ti83plus.inc. Using the one provided by TI doesn't change anything either. Also, the include instruction is from Buckydude himself. That makes me fairly certain of its validity.
Title: Re: ASM Help
Post by: calcdude84se on November 14, 2010, 08:31:47 pm
Are you sure you're including ti83plus.inc? SPASM likes to pretend that it's correctly assembled a program, when in fact, it has actually replaced any bad opcodes or labels with 0. This is bad if you have jp badLabel.
That's not very good. I didn't know SPASM did that :(

Also, does the ti83plus.inc file define it b_call or bcall? That could make a difference, since it would then not include the bcall at all.
And you are using the ti83plus.inc for SPASM, correct? Other versions might not work.
Title: Re: ASM Help
Post by: FloppusMaximus on November 14, 2010, 09:52:37 pm
If you're using the official ti83plus.inc from TI, that file uses ZMASM syntax for macros and equates.  I don't think spasm supports that syntax, or at least, it didn't the last time I checked.

Also, the official syntax defined by TI is "B_CALL PutS", not "bcall(_PutS)", so if you're using the official ti83plus.inc, it doesn't surprise me that the latter doesn't work.

It might help if you could post a listing file.
Title: Re: ASM Help
Post by: AngelFish on November 14, 2010, 09:54:02 pm
I tried both files.
Title: Re: ASM Help
Post by: FloppusMaximus on November 14, 2010, 10:20:30 pm
There are many different versions of ti83plus.inc floating around out there.  Which two, specifically, did you try?

For TASM - and I assume this would also work for SPASM - you'd want to include something along these lines, at the top of the file:
Code: [Select]
#define bcall(x) rst 28h \ .dw x
#define bjump(x) call BRT_JUMP0 \ .dw x
#define equ .equ
#define EQU .equ

Back in the day, when I used TASM, I liked to add:
Code: [Select]
.addinstr B_CALL * EF 3 NOP 1
.addinstr B_JUMP * 0050CD 5 NOP 1
which lets you write "B_CALL _PutS", a little bit closer to TI's official syntax.  I don't remember if SPASM supports addinstr.

In addition, you probably need to comment out the macro definitions later in the file.