Hi all;

I picked up a TI 84+SE so I could play around with Z80 assembler. I dont have a compiler or anything, so I write code on paper and converted it to hex to key into the calculator. I dont plan on writing anything big, so this works OK. Here's a program I wrote that displays 48 bytes of memory starting at address 9d95h, which displays this program. I tried to dump memory of some bcalls just to see what they looked like, but the results don't look like what I expected. Bcalls look like they are a table of 3 byte long calls or jumps to other addresses, but what I saw looked like ordinary code. Does that mean that the bcall code gets swapped in and out of the address where I think it is. If that's true, how do I swap areas of memory or is that too complicated. I spent the last few days looking thru the forum for this information, but I didn't find anything.

program to dump 48 bytes of memory.
current starting dump address is 9d95, which shows this program.
change the starting address to show different memory areas.

C3 b3 9d
4F
CD a1 9d
79
CD a5 9d
C9
1F
1F
1F
1F
E6 0F
F6 30
FE 3A
38 02
C6 07
EF 04 45
C9
21 95 9d ----->9d95, starting address to dump, low, high byte
06 30 ----->30, hex number of bytes to show (48 decimal)
7E
CD 98 9d
23
10 f9
C9

Thanks
Dave
It would be nice if you could give us the z80 version of the hex code.
tmwilliamlin168 wrote:
It would be nice if you could give us the z80 version of the hex code.

Umm... It's exactly the same. Just throw it into a dissasembler if your prefer.

Dave, to answer your question, you may want to look at the structure of the vector table for bcalls, available here:
http://wikiti.brandonw.net/index.php?title=83Plus:OS:ROMPage1B
In addition, you may want to explore how bcalls work. When you use "bcall(_something)", it's really just a macro.
http://wikiti.brandonw.net/index.php?title=83Plus:OS:How_BCALLs_work

You will need to work with memory mapping, which can be done by simply using the 'out' and 'in' instructions. Here's some more info:
http://wikiti.brandonw.net/index.php?title=83Plus:Ports:06
http://wikiti.brandonw.net/index.php?title=83Plus:Memory_Mapping
So, to swap in the bcall vector table for lookup:

Code:
push af
in a,(6)
push af
ld a,$7B
out (6),a
; do stuff to the vector table, such as grabbing addresses and things. Note that the address starts at $4000, not 0.
pop af
out (6),a
pop af
tmwilliamlin168;

Here's the code that I created the hex values from.


Code:

    jp start
top:
    ld c,a
    call shift
    ld a,c
    call andor
    ret
shift:
    rra
    rra
    rra
    rra
andor:
    and 0F
    or 30
    cp 3A
    jr c,disp
    add a,07
disp:
    bcall putc
    ret
start:
    ld hl,95 9d
    ld b,30
loop:
    ld a,(hl)
    call top
    inc hl
    djnz loop
    ret




MateoConLechuga;

Thanks for the information. I'll look thru it and see if it makes sense to me.
MateoConLechuga;

I looked thru the links you posted. I think that's a little over my head right now. I'll keep reading thru it and try to understand what's happening. I crash my calculator a lot because I don't convert the code to hex correctly some times. Swapping pages in and out probably adds more complexity to my conversion.
Please use an assembler to avoid the headache of mis-typing code. In addition, an emulator will let you save time debugging ASM, because you can keep testing new versions of your code without having to spend the time re-typing the program each time. Since you have a TI-84 Plus Silver Edition, you can use to dump a ROM image from your calculator, then use [url=http://sc.cemetech.net]SourceCoder 3 to both assemble and test your programs in your browser (it includes an editor, assembler, and emulator).
MateoConLechuga wrote:
tmwilliamlin168 wrote:
It would be nice if you could give us the z80 version of the hex code.

Umm... It's exactly the same. Just throw it into a dissasembler if your prefer.

Is there any disassembler that actually treats the 2 bytes after a bcall parameters instead of commands?
For example:

Code:

EF0145

A disassembler will treat the 01 and 45 as commands
tmwilliamlin168 wrote:
Is there any disassembler that actually treats the 2 bytes after a bcall parameters instead of commands?

Um, yes. RunerBot does a nice job. Copy and paste this into the sidebar chat window.


Code:
@z80 EFD74A
FE04C0
215500
22EC86227984
21F086
EB4E234623
ED43EE86
EDB0
3E05327884
EFF142
3803EFC64F
3E0521EC86
EF3C4C
C9


Oh, and here's Kerm's post in case you missed it: (Along with fixed links Razz)
KermMartian wrote:
Please use an assembler to avoid the headache of mis-typing code. In addition, an emulator will let you save time debugging ASM, because you can keep testing new versions of your code without having to spend the time re-typing the program each time. Since you have a TI-84 Plus Silver Edition, you can use rom8x to dump a ROM image from your calculator, then use SourceCoder 3 to both assemble and test your programs in your browser (it includes an editor, assembler, and emulator).
MateoConLechuga wrote:
tmwilliamlin168 wrote:
Is there any disassembler that actually treats the 2 bytes after a bcall parameters instead of commands?

Um, yes. RunerBot does a nice job. Copy and paste this into the sidebar chat window.


Code:
@z80 EFD74A
FE04C0
215500
22EC86227984
21F086
EB4E234623
ED43EE86
EDB0
3E05327884
EFF142
3803EFC64F
3E0521EC86
EF3C4C
C9


Runerbot can only handle short hex codes.
If you have access to an assembler, it really does make it easier, but I understand sometimes people don't have access to a computer or the software or hardware required for sending programs.


Now, to answer OP and make some clarifications. First, bcalls have an address that points to a spot in an look-up table. For example, _PutC is 4504h. On my calculator, this means that I need to load page 7B into membank1, and then look at the three bytes at 4504h. On my calc, these three bytes are "4C5B01" so the actual code for _PutC is located on page 01 at address 5B4Ch and starts with "F5E5FED62012".

By the way, if it helps to read that last code, char D6 is a newline, which jumps down a line and displays a colon.

Depending on the calc model, the bcalls may be located on page 3B and 3F or 1B and 1F.


Now here is my take on your hexdump program:

Code:

    ld hl,9D95h     ;21959D     ;address of where to read from
    ld bc,16        ;011000     ;number of bytes to dump
    in a,(6)        ;DB06       ;Save the current flash page
    ld d,a          ;57         ;/to restore later
    ld a,7Bh        ;3E7B       ;Set new flashpage in 4000h~7FFFh
    out (6),a       ;D306       ;/
dumploop:
    ld a,(hl)       ;7E         ;read a byte of mem at (hl)
    call DispLeft   ;CDB39D     ;Display the left nibble
    ld a,(hl)       ;7E         ;read the byte again
    call DispRight  ;CDB79D     ;display the left nibble
    cpi             ;EDA1       ;This is a cheap way to dec bc, inc hl
    jp pe,dumploop  ;EAA29D     ;If cpi does not set BC=0, loop again
    ld a,d          ;7A         ;We saved the flashpage in D
    out (6),a       ;D306       ;restore it
    ret             ;C9         ;exit
DispLeft:
    rrca            ;0F
    rrca            ;0F
    rrca            ;0F
    rrca            ;0F
DispRight:
    or $F0          ;F6F0       ;\
    daa             ;27         ; |Superduper convoluted way of
    add a,$A0       ;C6A0       ; |converting the lower nibble to ASCII
    adc a,$40       ;CE40       ;/
    bcall(_putc)    ;EF0445     ;Display the char, destroys no regs.
    ret             ;C9         ;exit this routine


But hte following should make it all much easier to dump bcalls. Where you would do EF0445 for bcall(_PutC), use 210445 at the start of this program and it will search for the bcall code and dump it.

Code:

    ld hl,_PutC     ;210445     ;_PutC=4504h
    ld bc,16        ;011000     ;number of bytes to dump
    in a,(6)        ;DB06
    push af         ;F5
    ld a,7Bh        ;3E7B       ;Change to 1B if on a TI-83+ (non-SE)
    bit 7,h         ;CB7C
    jr z,$+8        ;2806
    ld a,7Fh        ;3E7F       ;Change to 1F if on a TI-83+ (non-SE)
    res 7,h         ;CBBC
    set 6,h         ;CBF4
    out (6),a       ;D306
    ld e,(hl)       ;5E
    inc hl          ;23
    ld d,(hl)       ;56
    inc hl          ;23
    ld a,(hl)       ;7E
    out (6),a       ;D306
    ex de,hl        ;EB
dumploop:
    ld a,(hl)       ;7E         ;read a byte of mem at (hl)
    call DispLeft   ;CDC59D     ;Display the left nibble
    ld a,(hl)       ;7E         ;read the byte again
    call DispRight  ;CDC99D     ;display the left nibble
    cpi             ;EDA1       ;This is a cheap way to dec bc, inc hl
    jp pe,dumploop  ;EAB49D     ;If cpi does not set BC=0, loop again
    pop af          ;F1         ;We saved the flashpage in D
    out (6),a       ;D306       ;restore it
    ret             ;C9         ;exit
DispLeft:
    rrca            ;0F
    rrca            ;0F
    rrca            ;0F
    rrca            ;0F
DispRight:
    or $F0          ;F6F0       ;\
    daa             ;27         ; |Superduper convoluted way of
    add a,$A0       ;C6A0       ; |converting the lower nibble to ASCII
    adc a,$40       ;CE40       ;/
    bcall(_putc)    ;EF0445     ;Display the char, destroys no regs.
    ret             ;C9         ;exit this routine
Xeda112358; Thanks for the code and explanation. I just got my ROM loaded into the SouceCoder 3 emulator and I was going to add the code for the bank swapping into my original code and try it on the emulator. You saved me some time and also made a better version.
Xeda112358 Here's the dump of PutC using the address and page you show above. 5b4c is really 1b4c in page 1.


Code:


1B4C:    5f                  push af       
1B4D:    e5                 push hl       
1B4E:    fed6              cp $D6       
1B50:    2012             jr nz,$1B64       
1B52:    cdc561          call $61C5       
1B55:    cd4a5f           call $5F4A       
1B58:    3aa697          ld a,($97A6)       
1B5B:    6f                  ld l,a       
1B5C:    3a4b84          ld a,($844B)       
1B5F:    bd                 cp l       
1B60:    3013              jr nc,$1B75       
1B62:    3e3a              ld a,$3A       
1B64:    cd985a          call $5A98       
1B67:    fdcb0886        res preClrForMode,(iy+newDispF)       
1B6B:    214c84          ld hl,$844C       
1B6E:    34                 inc (hl)       
1B6F:    7e                 ld a,(hl)       
1B70:    fe10              cp $10       
1B72:    d44a5f          call nc,$5F4A       
1B75:    e1                pop hl       
1B76:    f1                 pop af       
1B77:    c9                ret

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