Recent Forum Posts
From categories:
page 1123...next »

Does anyone know how to, or has anyone successfully retrieved the program memory from a Z80 or Z80A? I have one, and would like to retrieve the code from it, not sure if it's possible or not, but because it's an older chip, I'm assuming that the failsafes we have in today's newer processors are not there.

Read Back program memory by jediengineerjediengineer, 16 Feb 2017 15:31

Suppose you want an 8-bit counter, ideally in A:

    xor a    ;performs 'ld a,0', but does affect flags, which isn't a problem here.
loop:
        ;Do stuff, but return with A unchanged
        ;Probably requires 'push af \ do stuff \ pop af'
        ;or 'ld (var_A),a \ do stuff \ ld a,(var_A)'
    inc a
    cp 10
    jr nz,loop      ;use jp if the loop is too far
        ;loop is finished, so return or do whatever you were going to do.

If you need a 16-bit counter, ideally in HL, it is a similar process:
    ld hl,0
loop:
        ;Do stuff, but return with HL unchanged
        ;Probably requires 'push hl \ do stuff \ pop hl'
        ;or 'ld (var_HL),hl \ do stuff \ ld hl,(var_HL)'
    inc hl
    ;push de     ;use if you need to preserve DE
    ld de,10
    or a      ;\
    sbc hl,de ; |This essentially compares HL and DE.
    add hl,de ;/
    ;pop de      ;use if you need to preserve DE
    jr nz,loop   ;use 'jp' if the jump is too far.
        ;loop is finished, so return or do whatever you were going to do.

Xeda96.pngXeda73.png
47%? Take a look and try to imagine how cool 100% will be. This has won zContest 2011 and made news on TICalc. This compromise between Assembly and BASIC parses like BASIC and is fast like assembly. Grammer 2
John (guest) 17 Oct 2016 19:20
in discussion Coding Forums / z80 programming » incremental loop in Z80

Well, it has been about 35 years… but from memory…

When any subtract (including compare and decrement) operation takes the register to zero you get your zero flag set and then you can jump or jump relative based on that. But when you are going up to a specified valume then you are going to have to do an explicit compare each time.
If it is an 8 bit value then you need to compare ("cp") with the value which you are testing if you are going up to; the compare is actually a subrtact but it throws the result away, just leaving the flags. You have to do the compare against the accumulator ("a"). So while "a" is different (non-zero flag set) to the value being tested against "jr" (or "jp") to the top of the loop. I think there are also sign bits you can check with "jp" which you could achieve a "<" operation with (remeber you are subtracting the value you are testing against from the "a" register, so if the result is negative ("m" flag) then you have not got there yet); this would have to be a signed computation, so take care if your values are over 127.
Αre you dealing with a 16 bit value? If so that is particularly difficult. Because if it is a 16 bit value then there is NO 16 bit compare operation. You'd be doing this against the "hl" pair probably (or else it gets even more complicated) I think I would probably be tempted to push "hl", subtract the value to test against and then pop "hl" again (the pop shouldn't affect the flags) then "jr" or "jp" based on the flags. The alternative is to compare the "h" and the "l" registers seperately. Discussion of what to do with the flags is as above… Though you'll have to have a jp or jr after each 8bit test…..
Hm. why not keep it simple and work out how many bytes, then use "djnz"?
Incidentally, I just noticed the page instructions-set:jr has "jp" in several places it should have "jr", if someone wants to fix that.
Hope this all makes sense; please don't flame me if I got something wrong… I was a teenager when I did any of this last.

by John (guest), 17 Oct 2016 19:20
incremental loop in Z80
bruno (guest) 29 Sep 2016 20:41
in discussion Coding Forums / z80 programming » incremental loop in Z80

DJNZ can be used to test a counter and loop until it reaches 0, but is there an easy way to loop until a counter reaches a certain value? Like in the following C code:
for (int i=0; i<10;i++) {
// do something with i
}

Thank you.

incremental loop in Z80 by bruno (guest), 29 Sep 2016 20:41

Hi,

It's not possible to say what this code fragment does because there is no context and you have given no information about it.
As pure code it's very straight forward but meaningless on it's own.

You mentioned it is to do with a game and about finding a place in France. So my best guess is that this is a patch file to add or change that feature in the game.

You should try and contact the game creators or a game players forum to find out what to do with it. Hope that helps :-)

In terms of size or speed, they are identical. I opt for ld de,() as it doesn't destroy HL and it it's more clear what outs going on. With that said, if DE already contains a value that you want in HL, definitely do it the other way.


Xeda96.pngXeda73.png
47%? Take a look and try to imagine how cool 100% will be. This has won zContest 2011 and made news on TICalc. This compromise between Assembly and BASIC parses like BASIC and is fast like assembly. Grammer 2

Hello,

So what I was wondering was if there were any disadvantages/advantages when it comes to LD DE,(xxxx) and LD HL,(xxxx) / EX HL,DE

I've used:

LD HL,(xxxx)
EX HL,DE

to get my Data into the DE register first, followed by getting the Data HL requires last, which saves using LD DE,(xxxx). At the end of it all it appears the same amount of opcodes are used as well as clock cycles, but was wondering if anyone knows any different?

Which of these is better? by Ross (guest), 17 Aug 2016 10:02
borilla (guest) 31 Jul 2016 06:35
in discussion Hidden / Per page discussions » CPIR

A very minor point but shouldn't the line A = HL (near the top of the article) read A = (HL), or perhaps even (HL) = A?

Likewise with CPDR

by borilla (guest), 31 Jul 2016 06:35

Hi,
I have received the following code to search a place in France. The game is cistes.net.

LD    BC, 11
NOP
LD    (DE), A
NOP
LD    BC, 22
JR    (PC + 8)
JR    (PC + 4)
ADD    HL, BC
DEC    B
JR    (PC + 6)
DEC    B
NOP
LD    BC, 33
LD    HL, 44
NOP
LD    D, 6
ADD    HL, BC
DEC    B
INC    B
NOP
INC    B
LD    HL, 55
NOP
LD    (DE), A
ADD    HL, BC
DEC    B
JR    (PC + 8)
JR    (PC + 4)
DEC    B
NOP
INC    B
DEC    B
NOP
LD    (DE), A
LD    BC, 77
NOP
INC    BC
EX    AF, AF'
LD    BC, 88
LD    D, 9
DEC    B
LD    (DE), A
LD    (DE), A
DEC    B
NOP
INC    D
INC    B
NOP
INC    B
DEC    B
NOP
INC    D
ADD    HL, BC
DEC    B
LD    12, (HL)
JR    (PC+8)
DEC    B
NOP
LD    BC, 21
NOP
LD    32, (HL)
LD    BC, 45
LD    HL, 76
INC    H
NOP
DEC    B
INC    D
NOP
LD    (BC), A
LD    HL, 53
RLCA
DEC    B
DEC    H

I have no idea what it means.

Please, somebody could tell me what that code do.
Thanks.

Help to understand what the program do by geracole (guest), 30 Jul 2016 16:29

Yes, you are correct. Good catch :)


Xeda96.pngXeda73.png
47%? Take a look and try to imagine how cool 100% will be. This has won zContest 2011 and made news on TICalc. This compromise between Assembly and BASIC parses like BASIC and is fast like assembly. Grammer 2
Re: LD A,0 vs XOR A by Xeda ElnaraXeda Elnara, 21 Jul 2016 13:24

The description says "A simple way to set a to zero. Don't use this if you want to preserve the accumulator." Shouldn't it be "Don't use this if you want to preserve flags." ?

LD A,0 vs XOR A by atornbladatornblad, 20 Jul 2016 10:54
Michael Latiolais (guest) 10 Jul 2016 21:26
in discussion Coding Forums / z80 programming » Weird Z80 behavior

The formatting looks weird. Here it is reformatted:
Writing: 0 from 1
Writing: 0 from 10
Writing: 0 from 11
Writing: 0 from 100
Writing: 0 from 101
Writing: 0 from 110
Writing: 0 from 111
Writing: 0 from 1000
Writing: 11000011 from 1001 < here is my JP opcode
Writing: 0 from 1010 < first part of the address
Writing: 0 from 1011 < second part
Writing: 0 from 0 < YAY! It jumped back to zero like expected!
Writing: 0 from 1010 < What is this?
Writing: 0 from 1 < Now it's incrementing two counters?
Writing: 0 from 1011
Writing: 0 from 10
Writing: 0 from 1100
Writing: 0 from 11
Writing: 0 from 1101
Writing: 0 from 100
Writing: 0 from 1110
Writing: 0 from 101
Writing: 0 from 1111
Writing: 0 from 110
Writing: 0 from 10000
Writing: 0 from 111
Writing: 0 from 10001
Writing: 0 from 1000
Writing: 0 from 10010
Writing: 11000011 from 1001 < It hit the JP opcode again
Writing: 0 from 10011 < What is this?
Writing: 0 from 1010 < Correct
Writing: 0 from 1011 < Correct
Writing: 0 from 0 < jump is still working
Writing: 0 from 10100 < Still counting?
Writing: 0 from 1
Writing: 0 from 10101
Writing: 0 from 10
Writing: 0 from 10110
Writing: 0 from 11
Writing: 0 from 10111
Writing: 0 from 100

by Michael Latiolais (guest), 10 Jul 2016 21:26
Weird Z80 behavior
Michael Latiolais (guest) 10 Jul 2016 21:24
in discussion Coding Forums / z80 programming » Weird Z80 behavior

Ok, I have a very basic Z80 system wired up with an Arduino and some shift registers. To test, I just had the Arduino look for MREQ, RD and M1 and then write out a byte. This was originally an array, but now I'm just looking for the 1001 location and writing out a JP opcode. Since it otherwise holds everything low, it should jump back to zero, and loop. And it does this. But I'm seeing something else(the first binary number is the data, second is the address requested by the Z80):
Writing: 0 from 1
Writing: 0 from 10
Writing: 0 from 11
Writing: 0 from 100
Writing: 0 from 101
Writing: 0 from 110
Writing: 0 from 111
Writing: 0 from 1000
Writing: 11000011 from 1001 <— here is my JP opcode
Writing: 0 from 1010 <first part of the address
Writing: 0 from 1011 <
second part
Writing: 0 from 0 <YAY! It jumped back to zero like expected!
Writing: 0 from 1010 <
What is this?
Writing: 0 from 1 <Why is the address bus incrementing two numbers?
Writing: 0 from 1011
Writing: 0 from 10
Writing: 0 from 1100
Writing: 0 from 11
Writing: 0 from 1101
Writing: 0 from 100
Writing: 0 from 1110
Writing: 0 from 101
Writing: 0 from 1111
Writing: 0 from 110
Writing: 0 from 10000
Writing: 0 from 111
Writing: 0 from 10001
Writing: 0 from 1000
Writing: 0 from 10010
Writing: 11000011 from 1001 <
It hit the JP opcode again
Writing: 0 from 10011 <What is this?
Writing: 0 from 1010 <
Correct
Writing: 0 from 1011 <— Correct
Writing: 0 from 0 <jump is still working
Writing: 0 from 10100 <
Still counting?
Writing: 0 from 1
Writing: 0 from 10101
Writing: 0 from 10
Writing: 0 from 10110
Writing: 0 from 11
Writing: 0 from 10111
Writing: 0 from 100

Weird Z80 behavior by Michael Latiolais (guest), 10 Jul 2016 21:24

blah blah


tibasicdevsig3.png
Fire Emblem for TI 83/4+ Progress: Demo: 75% Total: 40% Postponed indefinitely
Sample comment by The CowThe Cow, 10 Jan 2016 21:12
The CowThe Cow 08 Dec 2015 16:45
in discussion Hidden / Per page discussions » Input And Output

That is indeed correct. Fixing it now.


tibasicdevsig3.png
Fire Emblem for TI 83/4+ Progress: Demo: 75% Total: 40% Postponed indefinitely
by The CowThe Cow, 08 Dec 2015 16:45
Red CatRed Cat 04 Dec 2015 18:23
in discussion Hidden / Per page discussions » Input And Output

Note:

DisplayImage seems to want to use this picture format:

number of pixels down, number of pixels across

instead of what is listed here.

by Red CatRed Cat, 04 Dec 2015 18:23

Sorry I haven't checked z80-heaven in a month…

So on the page z80-basics, the code is:

#include "ti83plus.inc"
.org $9D93
.db $BB,$6D ; AsmPrgm
.define bcall(label) rst $28 \ .dw label

start:
 ld hl,txtHello
 bcall(_PutS)
 ret
txtHello:
.db "Hello World"

So some problems: PutS uses curRow and curCol, not PenRow and PenCol. I don't remember whether PenRow or PenCol comes first in the memory, but if PenRow comes first you are overwriting some byte in the memory with 0. Try changing this and see if it fixes it… if you haven't already in the last month…


tibasicdevsig3.png
Fire Emblem for TI 83/4+ Progress: Demo: 75% Total: 40% Postponed indefinitely

Hello all,
I've been trying to learn z80 assembly, and run it on my calculator, but I'm doing something wrong. Here is my tasm folder contents:

  • asm.bat
  • binpac8x.py
  • TASM.exe
  • TASM80.tab
  • ti83plus.inc

(I use binpac8x rather than DEVPAC8X because I am using a 64-bit version of windows)

Here is my ASM code:

.nolist
#include "ti83plus.inc"
#define    ProgStart    $9D95
.list
.org    ProgStart - 2
    .db    t2ByteTok, tAsmCmp
    bcall(_ClrLCDFull)
    ld    hl, 0
    ld    (PenCol), hl
    ld    hl, msg
    bcall(_PutS)            ; Display the text
    bcall(_NewLine)
    ret

msg:
    .db "Hello world!", 0
.end
.end

I am able to compile successfully, and load the .8xp file onto my calculator, but when I run

Asm(prgmHELLO)

On my ti-84 plus c silver edition, I get an ERR: INVALID message, and on my TI-84 plus silver edition, I just get a blank screen with the word "done" at the bottom. What am I doing wrong? Any suggestions?

Thanks, Cheers!

The CowThe Cow 25 Nov 2014 16:32
in discussion Hidden / Per page discussions » Coding

Fixed


tibasicdevsig3.png
Fire Emblem for TI 83/4+ Progress: Demo: 75% Total: 40% Postponed indefinitely
by The CowThe Cow, 25 Nov 2014 16:32
Chris (guest) 24 Nov 2014 22:34
in discussion Hidden / Per page discussions » Coding

There is a bug in the General Routine Setup section. The last line of code in the StrLength function should be jr StrLength10, not jr StrLength because it would cause the function to spin forever.

by Chris (guest), 24 Nov 2014 22:34
page 1123...next »
Unless otherwise stated, the content of this page is licensed under GNU Free Documentation License.