Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: darklink.perry on August 15, 2012, 02:03:17 pm

Title: ON break
Post by: darklink.perry on August 15, 2012, 02:03:17 pm
Can anyone help me? I learned the basics of assembly language a couple days ago, and I'm building one of my first long term programs. I need to keep people from breaking with the on button (one of the reasons why I turned to asm!) ???
Title: Re: ON break
Post by: Sorunome on August 15, 2012, 02:04:28 pm
Isn't that automatically as the basic interpreter breaks on ON?
EDIT: And Axe programs also don't break on ON ;)
Title: Re: ON break
Post by: darklink.perry on August 15, 2012, 02:18:45 pm
But the assembly program I've written can be broken by pressing On...
Title: Re: ON break
Post by: parserp on August 15, 2012, 02:18:51 pm
Yes, iirc the ON break is disabled automatically in asm.
But if you are familiar with BASIC I would strongly recommend you learn Axe Parser. (http://ourl.ca/4060/282749)
Title: Re: ON break
Post by: darklink.perry on August 15, 2012, 02:23:12 pm
Actually, I have learned that a while ago, but I still wanted to use Assembly.
Title: Re: ON break
Post by: ben_g on August 15, 2012, 02:23:40 pm
I think he means that his asm program breaks when he presses ON. If you don't use any OS routines (bcalls)(some will still work, but try it to be sure, and do that ON AN EMULATOR), then you can take full control by disabeling interrupts (the di instruction). This makes the CPU only run your code, so it won't do anything like breaking on ON, displaying the run indicator, etc. BUT it will also stop detecting keys when you don't use direct input. There should be a flag for this too, but I don't know which one.
Title: Re: ON break
Post by: darklink.perry on August 15, 2012, 02:25:46 pm
ben_g is exactly on the point. But does that mean that I really can't use any B_CALLs?
Title: Re: ON break
Post by: aeTIos on August 15, 2012, 02:27:47 pm
are you by any chance testing with mirageOS? iirc that has break on ON interrupt.
Title: Re: ON break
Post by: darklink.perry on August 15, 2012, 02:28:26 pm
I'm not using any shells. I'm just running it regularly.
Title: Re: ON break
Post by: aeTIos on August 15, 2012, 02:30:38 pm
hmm. Not totally sure but iirc bcall _getKey also breaks on ON. other than that i have no clue what could be causing this, never happened to me.
Title: Re: ON break
Post by: darklink.perry on August 15, 2012, 02:31:59 pm
I am in fact using B_CALL _getKey. I wanted to use GetCSC, but I want to detect if any key was pressed, and testing for each and every key would be inconvenient.
Title: Re: ON break
Post by: jacobly on August 15, 2012, 02:33:29 pm
B_CALL(_GetKey) returns with a = 0 when the ON key is pressed.  In order to use it again you need to res onInterrupt,(iy+onFlags).  Unfortunately, 2nd+ON can still exit the program during a B_CALL(_GetKey).  Fortunately, you can use B_CALL(_GetKeyRetOff) (which is what Axe uses) which returns kOff when 2nd+ON is pressed.  There might still be a link-port-related way to exit the program, but I don't know for sure.
Title: Re: ON break
Post by: darklink.perry on August 15, 2012, 03:26:56 pm
the GetKeyRetOff on compilation says it isn't a label or macro. if I throw out that command, it still does not stop the on key breakage.
Title: Re: ON break
Post by: jacobly on August 15, 2012, 03:28:57 pm
Get a more (http://brandonw.net/calcstuff/ti83plus.txt) complete (http://jacob.heliohost.org/calc/ti83plus.inc) ti83plus.inc.
Title: Re: ON break
Post by: ben_g on August 15, 2012, 03:30:07 pm
you can use B_Call($500B) instaed. It's the same.
Title: Re: ON break
Post by: darklink.perry on August 15, 2012, 03:40:27 pm
If I use the ti83plus.inc file jacobly provided, it gives me errors for all B_CALLs. If I use the B_CALL $500B, it waits for a keypress, and then continues, breaking on ON.
Title: Re: ON break
Post by: ben_g on August 15, 2012, 03:45:33 pm
Did you try adding
Code: [Select]
#define B_CALL(label) rst 28h \ .dw labelat the start of your code? (together with jacobly's .inc file), and do you call it with the brackets?
Title: Re: ON break
Post by: darklink.perry on August 15, 2012, 03:48:46 pm
If I add that, using your method returns the same, and using the provided include, all the B_CALLs return errors, all saying the same:
error: Macro B_CALL is missing arguments
Title: Re: ON break
Post by: ben_g on August 15, 2012, 03:55:08 pm
How do you call them? Do you do
Code: [Select]
B_CALL(_ExampleBCALL)or
Code: [Select]
B_CALL _ExampleBCALLAlso, is your assembler case-sensitive? If so, you might want to check the case. Also, don't forget the underscore at the front of the label.
Title: Re: ON break
Post by: darklink.perry on August 15, 2012, 03:56:53 pm
I use B_CALL _ExampleBCALL. And I use spasm.
Title: Re: ON break
Post by: darklink.perry on August 15, 2012, 04:02:59 pm
Is there a way to test if GetCSC returns with no keys pressed?
As in, if no keys are pressed, will it set off a flag?
Title: Re: ON break
Post by: ben_g on August 15, 2012, 04:40:19 pm
Try doing B_CALL(_ExampleBCALL), and GetCSC sets a to 0 if no key was pressed.
Title: Re: ON break
Post by: darklink.perry on August 15, 2012, 04:46:06 pm
Okay, when I use the other style, it works, but it still breaks on ON.
How frustrating.
Title: Re: ON break
Post by: darklink.perry on August 15, 2012, 04:51:05 pm
Okay, here's some code, if it helps.
.option BM_SHD = 2

.option bm_min_w = 96

#define B_CALL(label) rst 28h \ .dw label

#include "ti83plus.inc"

.org $9D93

.db t2ByteTok, tAsmCmp

      B_CALL(_RunIndicOff)
      ld hl, Splash_Screen
      ld de, plotsscreen
      ld bc, 768
      ldir
      
      B_CALL(_GrBufCpy)
      res onInterrupt,(iy+onFlags)
      B_CALL(_GetKeyRetOff)
      B_CALL(_ClrLCDFull)
      
      ret

Splash_Screen:

#include "images/logo.bmp"
Title: Re: ON break
Post by: jacobly on August 15, 2012, 04:52:47 pm
The OS didn't actually interrupt your code.  If your code exits with onInterrupt,(iy+onFlags) set, then the break error automatically shows up after your program exits.

Edit: and the flag is automatically set when ON is pressed in B_CALL(_GetKey).

Edit 2: ...so all you have to do is put res onInterrupt,(iy+onFlags) before you return.
Title: Re: ON break
Post by: darklink.perry on August 15, 2012, 04:54:43 pm
But it doesn't come up with a break error until I press ON. If I press any other button, then it shows the error.
Title: Re: ON break
Post by: darklink.perry on August 15, 2012, 05:23:21 pm
Aha! It works! Thank you SO MUCH!