z80 | A csharp emulator for the Zilog Z80 CPU
kandi X-RAY | z80 Summary
kandi X-RAY | z80 Summary
A csharp emulator for the Zilog Z80 CPU.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of z80
z80 Key Features
z80 Examples and Code Snippets
Community Discussions
Trending Discussions on z80
QUESTION
I am attempting to run the following code:
...ANSWER
Answered 2021-Dec-24 at 03:16The problem with your code is that $+4 and $-7 are both referring to byte counts, not instruction counts, and the JR instruction is 2 bytes. The indentation gives you a clue. You need to move your labels:
QUESTION
Background information
As a modern days PHP developer with a passing interest in 8-bit technologies, I'm a little sketchy on real low level stuff. Although I've worked with the Z80 processor, and done some MIPs assembly at University, I'm least well versed in the 65x processor family.
What I'm trying to achieve
What I want to do is to relocate the zero page to 0xd300 for my application - I've had a obligatory Internet search but am not able to find a good example that I am able to understand. I'm working in 65c02 but on a 65816 processor; I have found out, thanks to a friend, that you can only relocate the zero page in native mode, not emulation mode as it's not supported by the 65c02. This isn't an issue as I can switch to native mode for what I'm doing and revert to emulation mode should I want to return gracefully to BASIC (well, not only that I know).
If someone could also provide an example for the 8502 (Commodore C128) as well please as I know that has a relocatable zero page. I know that's two questions in one, but it's related to what I want to do.
...ANSWER
Answered 2021-Oct-19 at 06:35The Direct Page register D
is a 16-bit register specifying which 256-byte page within bank 0 that should be the current Direct Page (what you call Zero Page).
There are a couple of different instructions you can use to write to D
. So e.g. something like this should work:
QUESTION
This is my code:
...ANSWER
Answered 2021-Sep-15 at 08:17It helps if you read the manual.
The main error: Only labels start in the first column, insert at least a space or tab before any instruction or pseudo instruction.
ejemplo1.asm(1) : Unrecognized instruction: "ejemplo1.
output
is interpreted as label, and consequently the filename is tried as an instruction. The interesting detail is that the point "." is taken as a separator. BTW, the filename is not in quotation marks, according to the examples.
ejemplo1.asm(3) : Label not found: fe
db
is interpreted as label, and perhaps #fe
is interpreted as a structure field entry. #
defines the length on a field, and therefore fe
is not recognized as a number, but as a label. This interpretation looks like a bug in the assembler to me.
ejemplo1.asm(4) : Unrecognized instruction: start
dw
is interpreted as label, and consequently start
is tried as an instruction.
ejemplo1.asm(5) : Duplicate labelname: dw
dw
is again interpreted as label, as the error message tells us that it is already defined (in the line before).
Note: If you correct your code and get new errors, feel free to post a new question. You might want to add this to this question, but don't remove the current contents, add it and mark it as addition.
QUESTION
While exploring joystick connection to the Z80 games I've got this code, which should print 1 letter when I press Up, Left or Right. But for some reason when I press Left it prints lru
, when I press Right it prints ru
, and u
after pressing Up.
ANSWER
Answered 2021-Aug-27 at 18:14The subroutines change the value of the BC
register so if one of them is called the subsequent IN A,(C)
instructions will read the wrong port.
Put a LD BC,31
before every IN A,(C)
to fix this. Or you could save and restore BC
in the subroutines with a push and pop like so:
QUESTION
While learning Z80 assembly I've go a strange behavior that after declaring 2 numeric variables the value of the first one gets a totally different value.
Example:
...ANSWER
Answered 2021-Aug-25 at 16:42Yes, exactly; using defw
will increase the size of the data (2 bytes each) to match the data size specification of the instruction being used in code.
Code and data sizes have to match; each instruction that references data tells the CPU what size the data has, and, data declarations also have a size. In many assembly languages, consistency is programmer responsibility — assemblers often do not complain about (size) mismatches.
The CPU never sees data declarations, it only sees instructions. So, each and every time an instruction references data, it has to specify how (i.e. the data size). The CPU doesn't remember or care about mismatches between code in one place and code in another place, or between code & data; it just takes one instruction at a time and does what that says.
Expanding the data to match what the code does is the easiest fix here because your print subroutine takes the argument to print in the bc
16-bit register pair.
Otherwise, you can change the instruction to use the same size load as the defb
, namely byte-sized instead of word-sized. This would be done using an instruction like LD c,(score1)
, which loads only the c
8-bit register — and this is appropriate for data declared to 8-bits using defb
.
To continue and use the print function, however, since the print expects a value in 16-bit bc
, the 8-bit value in c
will have to be expanded to a 16-bit value in bc
, by clearing b
(set b
to 0, or by sign extending into b
).
If I got the endian wrong, then swap references to the 8-bit registers with one letters b
and c
in what I said above.
QUESTION
Is there a way to delete the variable id
with other dx
than "I10"?
ANSWER
Answered 2021-Jan-21 at 02:49You can select the id's where all the values are 'I10'
Using dplyr
:
QUESTION
I want to write a game loop on CP/M 2.X (Z80) and would need to wait for some time e.g. a second. I've looked at BDOS but did not find a function, a loop depends on processor (emulation speed), interrupts like vertical blank do not exist.
Any ideas on how to write a game loop?
[Edit]
The z88dk CP/M lib says
Not (of course) CPM 1.x and 2.x, which have no real-time functions; ,nor QX/M, its clock is not BCD based.
There were action games like LADDER so there should be a way for a game loop.
[Edit2]
I could let the user check 5 secs with two keypresses and measure the speed (double loop) once to config the game - but only as a last resort.
...ANSWER
Answered 2021-Jan-18 at 20:23There's no portable way of waiting for a certain amount of time under CP/M 2.2. CP/M doesn't require or use a real time clock or any kind of timer, and so you can't even assume one is present in the system, let alone that it uses any kind of common interface.
Turbo Pascal's Delay
function worked by assuming a certain CPU frequency, one that was configured when Turbo Pascal was installed. The CP/M game Ladder was written in Turbo Pascal and used its Delay
function, so it also assumed a certain CPU frequency. If you played on a faster or slower CPU the game would play faster or slower than intended.
The simplest solution would be to implement your own delay function that assumed a certain CPU frequency. I believe 4 MHz was the most common Z80 speed for CP/M. You can make this a configurable option so users can change the assumed CPU speed. You're probably also going to want to give users the option of changing the terminal type, just like Ladder did, as there are many possible terminals that can be used with CP/M.
QUESTION
I'm trying to learn Z80 assembly - and forgive me if this is extremely obvious - but I'm rather new to assembly as a whole.
I have familiarised myself with how jumps work after making a comparison with cp
and how they equate to things I know, that NZ
is the equivilant of "!=", C
correlates to "<" and so on. Though from as far as I've been able to see, ">" isn't as easy.
NC
is the opposite of C
, NC
- as I understand - correlates to ">=" in my scenario. My assumption is that I can combine NC
and NZ
in the same jump condition to remove the "=" so to speak, but it doesn't seem to work.
What can I do to make my jump's condition be that a
is more than the compared amount, without allowing them to equal zero?
ANSWER
Answered 2020-Nov-06 at 15:10CP
performs a subtraction and sets the flags appropriately. It doesn't store the results of the subtraction.
So to compare for the A greater than the operand, you need to look for a result of that subtraction that was a strictly positive number, i.e. it was 1 or greater.
There's no direct route to that, you'll have to do it as a compound — NC
to eliminate all results less than 0, getting you to greater than or equal, followed by NZ
to eliminate the possibility of equality. But you might want to flip those for more straightforward code. E.g.
QUESTION
Lets say i have a data (15H) on memory 0040.
My question is, how an I extract that most significant and least significant bit for further usage?
I have lookup on the Z80 User manual and found nothing. Any help will be appreciated
...ANSWER
Answered 2020-Oct-28 at 17:51I just want to wrote down what @Jester already explained to me
how to get the LSB- using AND
QUESTION
Bear in mind this is an old version of the C compiler: CP/M for Z80.
...ANSWER
Answered 2020-Jun-20 at 10:00Golly. LONG time since I used a z80 C compiler, and most were buggy as [unprintable] back then. I would suggest that you dump the assembler if the compiler allows. My GUESS is that internally the char is being promoted to a 16 bit INT with indeterminate upper bits set.
The problem is that %04X expects an integer - not a char.
You might try forcing the compiler to play nice by explicitly casting the char to an int - i.e.
printf("0x%04x | ", (int) i);
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install z80
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page