Hey, I'm going to learn ASM (I know a bit), and I've some questions:

1. bit editOpen, (iy+editFlags) doesn't seem to work for me on the 84+
2. How can I return to the ASM program after _ExecuteNewPrgm? (It returns to the homescreen)
3. Can you load the carry flag directly in another bit?
4. Can you run a BASIC program from ASM without deleting and recreating it?

More questions are following Wink

Thanks in advance! Smile
PT_ wrote:
1. bit editOpen, (iy+editFlags) doesn't seem to work for me on the 84+

Hm, how are you using it?

PT_ wrote:
How can I return to the ASM program after _ExecuteNewPrgm? (It returns to the homescreen)

Not quite sure what you mean here, could you please elaborate? Smile
PT_ wrote:
3. Can you load the carry flag directly in another bit?

Is this what you need?:

Code:
; Carry flag -> Zero flag.
 ccf
 sbc a,a


PT_ wrote:
4. Can you run a BASIC program from ASM without deleting and recreating it?

Sure, this code installs an error handler that you can use to do whatever you like if the BASIC program hits an error:

Code:
RunBasicProgram:
 set graphdraw,(iy+graphFlags)
 ld hl,errcatch
 bcall(_PushErrorHandler)
  set ProgExecuting,(iy+newdispf)
  set allowProgTokens,(iy+newDispF)
  set cmdExec,(iy+cmdFlags)
  res onInterrupt,(iy+onflags)
  bcall(_ParseInp)            ; run program [/quote]
 bcall(_PopErrorHandler)   
 xor a
errcatch:
 push af
  bcall(_CleanAll)
  bcall(_DeleteTempPrograms)
  res ProgExecuting,(IY+newDispf)
  res cmdExec,(IY+cmdFlags)
  res textInverse,(iy+textFlags)
  res allowProgTokens,(iy+newDispF)
  res onInterrupt,(iy+onFlags)
 pop af
 or a
 ret z
;## HANDLE BASIC ERRORS HERE
 ret
Wow, many thanks so far! For running a BASIC program, I don't need error checking because it runs only 1 program and I'm sure I will test it, so that no error occur.
MateoConLechuga wrote:
PT_ wrote:
How can I return to the ASM program after _ExecuteNewPrgm? (It returns to the homescreen)

Not quite sure what you mean here, could you please elaborate? Smile

It works so:
I've created an ASM program, that installs a key hook.
If someone anywhere press [LINK], it executes some code. I hope you understand this Razz
That code is first checking if my prgmR exist, and if so, it runs the program.
But if you pressed [LINK] in the program editor, my aim is to return to the editor after running that program, because now it just returns to the homescreen.
Hope this helps! Smile

5. How can I insert text at the cursor in ASM? Let's say you read Ans as a string, and that would be inserted at either the homescreen or in the program editor.
EDIT: it seems to do something with Recall Queue

6.

Code:
ld hl, hook_addr + varname - hook_start (or just varname without a hook)
bcall(_Mov9ToOP1)
bcall(_ChkFindSym)
ret c
set allowProgTokens,(iy+newDispF)
bcall(_ParseInp)

works fine without a hook, but if I nested it in a key hook, it gives me a Memory Error. Why?
PT_ wrote:
But if you pressed [LINK] in the program editor, my aim is to return to the editor after running that program, because now it just returns to the homescreen.
Hope this helps! Smile
It seems to me that you need to check the context when your hook starts, and if it's the editor, it needs to close the editor context, run the program, then re-launch the editor context. See also below.

PT_ wrote:
6.
Code:
ld hl, hook_addr + varname - hook_start (or just varname without a hook)
bcall(_Mov9ToOP1)
bcall(_ChkFindSym)
ret c
set allowProgTokens,(iy+newDispF)
bcall(_ParseInp)

works fine without a hook, but if I nested it in a key hook, it gives me a Memory Error. Why?
If the editor context is open, it inserts the entirety of your free RAM into the program it's editing. When you close the editor, it returns any unused RAM back to the free RAM pool. If you're calling _ParseInp from a keyhook, you need to make sure that the editor context is not active, and if it is, you probably need to close it first.

Edit: To close the editor context, you either want to go through the _NewContext rigmarole with a new context of cxQuit/kQuit (that is, the Homescreen), or just call _Putaway on the editor context, then _NewContext afterwards. I don't like the latter solution, because being in no context at all sounds dangerous.

Code:
ld a, kQuit
bcall(_NewContext)
set allowProgTokens,(iy+newDispF)
bcall(_ParseInp)
still doesn't work within the key hook. Any ideas?
Kerm, I feel as if you are one of the few who understands the edit buffers well. I have never seen, and could not find one when looking for one, an example of them being used. Could you point PT_ (and me) to an example of them being used?
Hooloovoo wrote:
Kerm, I feel as if you are one of the few who understands the edit buffers well. I have never seen, and could not find one when looking for one, an example of them being used. Could you point PT_ (and me) to an example of them being used?

It's not definitely the edit buffer, my program didn't work from the homescreen as well. I'm only asking a small (?) code snippet for running a BASIC program with ASM in a key hook from the homescreen. Additionally, it would be fine if it could be done from the program editor.
*bump*
I've still no idea how to do such stuff, and where I can find it. I've tried the code on WikiTI - don't help. Even Googled it - nothing found. Please please please could someone write a code snippet for me (and other?) that does the following:
- Check if you'r in the program editor/edit buffer (bit editOpen doesn't seems to work)
- Run a BASIC program which name is in OP1 (the standard) - no Memory Error please Very Happy
- After that program run, returns to the ASM program which calls the BASIC program
- Return to the program editor/edit buffer

See also my other posts in this topic.

If you don't understand it, please ask me Very Happy Very Happy

Good Idea Good Idea Good Idea Good Idea Good Idea
See my post above! Smile

Another question: how can I disassemble a part of the OS. I.e. what should I do when I want to know how _ParseInp works? I had the idea to do

Code:
ld hl, _ParseInp
bcall(_PutS)
bcall(_GetKey)
ret

but then I got a bunch of BASIC-commands, which is hard to translate to hex.
My second try was to load the contents of _PutS into the graphscreen, and make a BASIC program to get it, but I don't get normal ASM I guess Wink

Code:
                           .data:00000000 0e 05                            ld c,0x05
                           .data:00000002 02                               ld (bc),a
                           .data:00000003 04                               inc b
                           .data:00000004 00                               nop
                           .data:00000005 0c                               inc c
                           .data:00000006 04                               inc b
                           .data:00000007 04                               inc b
                           .data:00000008 0e 05                            ld c,0x05
                           .data:0000000a 08                               ex af,af'
                           .data:0000000b 04                               inc b
                           .data:0000000c 00                               nop
                           .data:0000000d 0c                               inc c
                           .data:0000000e 04                               inc b
                           .data:0000000f 04                               inc b
                           .data:00000010 0e 05                            ld c,0x05
                           .data:00000012 04                               inc b
                           .data:00000013 0a                               ld a,(bc)
                           .data:00000014 00                               nop
                           .data:00000015 0c                               inc c
                           .data:00000016 04                               inc b
                           .data:00000017 04                               inc b
                           .data:00000018 0e 05                            ld c,0x05
                           .data:0000001a 0a                               ld a,(bc)
                           .data:0000001b 00                               nop
                           .data:0000001c 00                               nop
                           .data:0000001d 0c                               inc c
                           .data:0000001e 04                               inc b
                           .data:0000001f 04                               inc b
                           .data:00000020 0e 05                            ld c,0x05
                           .data:00000022 02                               ld (bc),a
                           .data:00000023 04                               inc b
                           .data:00000024 0e 11                            ld c,0x11
                           .data:00000026 11 11 0e                         ld de,0x0e11
                           .data:00000029 05                               dec b
                           .data:0000002a 08                               ex af,af'
                           .data:0000002b 04                               inc b
                           .data:0000002c 0e 11                            ld c,0x11
                           .data:0000002e 11 10 0e                         ld de,0x0e10
                           .data:00000031 05                               dec b
                           .data:00000032 04                               inc b
                           .data:00000033 0a                               ld a,(bc)
                           .data:00000034 0e 11                            ld c,0x11
                           .data:00000036 11 11 0e                         ld de,0x0e11
                           .data:00000039 05                               dec b
                           .data:0000003a 0a                               ld a,(bc)
                           .data:0000003b 00                               nop
                           .data:0000003c 0e 11                            ld c,0x11
                           .data:0000003e 11 11 0e                         ld de,0x0e11
                           .data:00000041 05                               dec b
                           .data:00000042 02                               ld (bc),a
                           .data:00000043 04                               inc b
                           .data:00000044 00                               nop
                           .data:00000045 0e 11                            ld c,0x11
                           .data:00000047 10 0e                            djnz 0x0057
                           .data:00000049 05                               dec b
                           .data:0000004a 08                               ex af,af'
                           .data:0000004b 04                               inc b
                           .data:0000004c 00                               nop
                           .data:0000004d 0e 11                            ld c,0x11
                           .data:0000004f 11 0e 05                         ld de,0x050e
                           .data:00000052 04                               inc b
                           .data:00000053 0a                               ld a,(bc)
                           .data:00000054 00                               nop
                           .data:00000055 0e 11                            ld c,0x11
                           .data:00000057 11 0e 05                         ld de,0x050e
                           .data:0000005a 0a                               ld a,(bc)
                           .data:0000005b 00                               nop
                           .data:0000005c 00                               nop
                           .data:0000005d 0e 11                            ld c,0x11
                           .data:0000005f 10 0e                            djnz 0x006f
                           .data:00000061 05                               dec b
                           .data:00000062 02                               ld (bc),a
                           .data:00000063 04                               inc b
                           .data:00000064 11 11 11                         ld de,0x1111
                           .data:00000067 11 0e 05                         ld de,0x050e
                           .data:0000006a 08                               ex af,af'
                           .data:0000006b 04                               inc b
                           .data:0000006c 11 11 11                         ld de,0x1111
                           .data:0000006f 11 0e 05                         ld de,0x050e
                           .data:00000072 04                               inc b
                           .data:00000073 0a                               ld a,(bc)
                           .data:00000074 00                               nop
                           .data:00000075 11 11 10                         ld de,0x1011
                           .data:00000078 0e 05                            ld c,0x05
                           .data:0000007a 0a                               ld a,(bc)
                           .data:0000007b 00                               nop
                           .data:0000007c 11 11 11                         ld de,0x1111
                           .data:0000007f 11 0e 05                         ld de,0x050e
                           .data:00000082 02                               ld (bc),a
                           .data:00000083 04                               inc b
                           .data:00000084 11 11 11                         ld de,0x1111
                           .data:00000087 13                               inc de
                           .data:00000088 0d                               dec c
                           .data:00000089 05                               dec b
                           .data:0000008a 08                               ex af,af'
                           .data:0000008b 04                               inc b
                           .data:0000008c 11 11 11                         ld de,0x1111
                           .data:0000008f 12                               ld (de),a
                           .data:00000090 0d                               dec c
                           .data:00000091 05                               dec b
                           .data:00000092 04                               inc b
                           .data:00000093 0a                               ld a,(bc)
                           .data:00000094 00                               nop
                           .data:00000095 11 11 13                         ld de,0x1311
                           .data:00000098 0d                               dec c
                           .data:00000099 05                               dec b
                           .data:0000009a 0a                               ld a,(bc)
                           .data:0000009b 00                               nop
                           .data:0000009c 11 11 11                         ld de,0x1111
                           .data:0000009f 13                               inc de
                           .data:000000a0 0d                               dec c
                           .data:000000a1 05                               dec b
                           .data:000000a2 0e 11                            ld c,0x11
                           .data:000000a4 10 11                            djnz 0x00b7
                           .data:000000a6 0e 04                            ld c,0x04
                           .data:000000a8 1c                               inc e
                           .data:000000a9 05                               dec b
                           .data:000000aa 00                               nop
                           .data:000000ab 00                               nop
                           .data:000000ac 0e 10                            ld c,0x10
                           .data:000000ae 11 0e 1c                         ld de,0x1c0e
                           .data:000000b1 05                               dec b
                           .data:000000b2 05                               dec b
                           .data:000000b3 0a                               ld a,(bc)
                           .data:000000b4 11 19 15                         ld de,0x1519
                           .data:000000b7 13                               inc de
                           .data:000000b8 11 05 05                         ld de,0x0505
                           .data:000000bb 0a                               ld a,(bc)
                           .data:000000bc 00                               nop
                           .data:000000bd 16 19                            ld d,0x19
                           .data:000000bf 10 11                            djnz 0x00d2
                           .data:000000c1 05                               dec b
                           .data:000000c2 01 02 04                         ld bc,0x0402
                           .data:000000c5 00                               nop
                           .data:000000c6 00                               nop
                           .data:000000c7 00                               nop
                           .data:000000c8 00                               nop
                           .data:000000c9 05                               dec b
                           .data:000000ca 10 08                            djnz 0x00d4
                           .data:000000cc 04                               inc b
                           .data:000000cd 00                               nop
                           .data:000000ce 00                               nop
                           .data:000000cf 00                               nop
                           .data:000000d0 00                               nop
                           .data:000000d1 05                               dec b
                           .data:000000d2 00                               nop
                           .data:000000d3 0a                               ld a,(bc)
                           .data:000000d4 00                               nop
                           .data:000000d5 00                               nop
You're going about it the wrong way, the easiest way would be either to disassemble the OS or use the debugger of an emulator to step through the instructions until you actually get to the bcall code. The EF opcode (bcall) will jump to the address $0028, do some magic to save the current flash page we're on, find the address of the bcall (the two bytes after the EF opcode), which flash page to load based on the bcall, jump to the code (look for a bunch of pops followed by a ret), restore the flash page, and quit. Calling _PutS treats the assembly instructions as (TI) ASCII characters and will continue drawing until it comes across a 0.
chickendude wrote:
You're going about it the wrong way, the easiest way would be either to disassemble the OS or use the debugger of an emulator to step through the instructions until you actually get to the bcall code. The EF opcode (bcall) will jump to the address $0028, do some magic to save the current flash page we're on, find the address of the bcall (the two bytes after the EF opcode), which flash page to load based on the bcall, jump to the code (look for a bunch of pops followed by a ret), restore the flash page, and quit. Calling _PutS treats the assembly instructions as (TI) ASCII characters and will continue drawing until it comes across a 0.

So in fact the two bytes after EF tells the OS which flash page to load? Each time you call _PutS, is it always the same flash page?
I second chickendude's opinion: stepping through the bcall in an emulator is the easiest way to see how it works. Single-step through the bcall setup code he described; you'll know when it's ending because the OS pops most of the registers and returns. You'll then be in the meat of the call's code; make a note of the page and address of the start of the call, and if you want to see it again, you can avoid the bcall setup code by just setting a breakpoint at that address.
I'm diving into ez80 programming, but that seems to be hard Wink
I know how to turn the screen black in ASM, but I can't access single pixels Sad
Can anyone help me?
I've this so far:

Code:
#include "includes\ti84pce.inc"

.assume ADL=1
.org userMem-2
.db tExtTok,tAsm84CeCmp

start:
   ld a,lcdBpp8
   ld (mpLcdCtrl),a
   ld hl, vRAM
   ld a, 0
   ld (hl), 0
   ld de, vRAM+1
   ld bc, 320*240
   ldir
   ld hl, vRAM+320*50+50
   ld (hl), 6
   ;call _GetKey
   ld a,lcdBpp16
   ld (mpLcdCtrl),a
   ret
PT_ wrote:
I'm diving into ez80 programming, but that seems to be hard Wink
I know how to turn the screen black in ASM, but I can't access single pixels Sad
Can anyone help me?


Looks like you need to set up your palette. This page:
http://wikiti.brandonw.net/index.php?title=84PCE:Ports:4000
Will provide some more information. Simply search for CopyHL1555Palette. Hope this helps! Smile
SPASM-ng's order of operations REALLY, REALLY sucks:

Code:
ld hl, vRAM+320*50+50

It turns this into ((VRAM+320)*50)+50. That's VRAM*50 + 320*50 + 50.

Edit: To quote SPASM-ng's manual:
Quote:
SPASM uses no-questions-asked order of operations: left-to-right. This is prefered for speed reasons as well as ambiguity between operators -- who really knows which of these operators should come first? % or &?
^ This is the laziest nonsense ever and makes me sad. Besides being terribly unintuitive for anyone who (1) has learned math, or (2) programmed in any other language, it teaches programmers terrible habits if they haven't programmed in other languages before. I intend to fix this in SPASM-ng at some point.
I saw that SC supports ez80, but how would the header look like?
And how is the ti84pce include file called?
When looking at the Parser Hook at WikiTi, what value should I load in HL, if it should be an Asm( token, instead of sin( (for example), and how would I know that?
Btw, this is in ez80, if that makes difference.
I'm trying to get the countdown in ez80 working (see this), but it didn't start to count down Sad
Here is my code:

Code:
#include "header.asm" ; standard header

   ld hl, $F10004
   ld de, $FFFFFF
   ld (hl),de
   inc hl
   ld (hl),de
   ld hl, $F10008
   ld (hl), $B9
   inc hl
   ld (hl), $5A
   ret

When I tested this in CEmu, the debugger told me it won't count down, although it has the right value in it Smile
Any suggestions to make this working? Thanks! Smile
I dunno much about ez80 asm, but from the doc you linked I'd say you also need to set bit 0 of (F1000C).
utz wrote:
I dunno much about ez80 asm, but from the doc you linked I'd say you also need to set bit 0 of (F1000C).

I somehow removed a part of my code :O
This is my full code:

Code:
#include "header.asm"

   ld hl, $F10004
   ld de, $012345
   ld (hl),de
   inc hl
   ld (hl),de
   ld hl, $F10008
   ld (hl), $B9
   inc hl
   ld (hl), $5A
   ld a, %11001
   ld ($F1000C), a
   ld hl, ($F10000)
   call _SetXXXXOP2
   call _OP2ToOP1
   call _StoAns
   ret

^ that doesn't help anything Sad

  
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 4
» 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