473,324 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

8085 simulator in C

Hi everyone,

Can anyone give some idea about developing an 8085 simulator
program in C? What techniques can be handled to develop this?

Jun 4 '07 #1
18 5619
In article <11**********************@x35g2000prf.googlegroups .com>,
ac***********@gmail.com <ac***********@gmail.comwrote:
Can anyone give some idea about developing an 8085 simulator
program in C? What techniques can be handled to develop this?
-Personally-, I wouldn't bother unless it was an assignment or
a pet learning project (and even then, I'd reconsider whether
8085 was the right choice of processors.)

If you wanted an 8085 simulator, I'd look around and try out
http://sourceforge.net/projects/sim85
or Vaneet Singla's 8085 simulator (available in a wide variety of places)
--
If you lie to the compiler, it will get its revenge. -- Henry Spencer
Jun 4 '07 #2
On Jun 4, 11:15 am, "activearun...@gmail.com"
<activearun...@gmail.comwrote:
Hi everyone,

Can anyone give some idea about developing an 8085 simulator
program in C? What techniques can be handled to develop this?
http://www.google.com/search?hl=en&q...=Google+Search

Jun 4 '07 #3
On Jun 4, 1:30 pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
In article <1180980953.503669.203...@x35g2000prf.googlegroups .com>,

activearun...@gmail.com <activearun...@gmail.comwrote:
Can anyone give some idea about developing an 8085 simulator
program in C? What techniques can be handled to develop this?

-Personally-, I wouldn't bother unless it was an assignment or
a pet learning project (and even then, I'd reconsider whether
8085 was the right choice of processors.)
I don't think 8085 is such a bad choice. Very simple instruction set.
I did this one weekend about 20 years ago just for the heck of it. I
had an old single board PC I wanted to emulate on a VAX.

The OP wanted suggestions on techniques to do this. As I recall, the
upper nibble of the opcode pretty much tells you what the instruction
will do, so I made an array of 16 functions and used the upper nibble
to index into the array. Then I had 16 individual functions to handle
the operations. The lower nibble is mostly for addressing, so that too
can index into an array for the correct register. Setting the flags
properly was the trickiest part.

Jun 5 '07 #4
ms*******@yahoo.com writes:
The OP wanted suggestions on techniques to do this. As I recall, the
upper nibble of the opcode pretty much tells you what the instruction
will do, so I made an array of 16 functions and used the upper nibble
to index into the array. Then I had 16 individual functions to handle
the operations. The lower nibble is mostly for addressing, so that too
can index into an array for the correct register. Setting the flags
properly was the trickiest part.
This sounds like a fun instruction set on which to practice
writing a (static or dynamic) binary translator. (Of course,
there's no way to actually run the translated code without
invoking undefined behavior, from a comp.lang.c point of view.)
--
Ben Pfaff
http://benpfaff.org
Jun 5 '07 #5
In article <11*********************@w5g2000hsg.googlegroups.c om>,
ms*******@yahoo.com writes
>On Jun 4, 1:30 pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
>In article <1180980953.503669.203...@x35g2000prf.googlegroups .com>,

activearun...@gmail.com <activearun...@gmail.comwrote:
Can anyone give some idea about developing an 8085 simulator
program in C? What techniques can be handled to develop this?

-Personally-, I wouldn't bother unless it was an assignment or
a pet learning project (and even then, I'd reconsider whether
8085 was the right choice of processors.)

I don't think 8085 is such a bad choice.
It is if you want o buy one... I am certain the are obsolete these
days,.
Very simple instruction set.
I did this one weekend about 20 years ago just for the heck of it. I
had an old single board PC I wanted to emulate on a VAX.
Exactly....20 years ago It might be technically nice but getting the HW
is another matter. As for the tools.... i will dust of the compiler on
the 5.25" floppies.....

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Jun 5 '07 #6
On Jun 5, 10:45 am, Chris Hills <c...@phaedsys.orgwrote:
In article <1181057388.694969.70...@w5g2000hsg.googlegroups.c om>,
mstork...@yahoo.com writes>On Jun 4, 1:30 pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
In article <1180980953.503669.203...@x35g2000prf.googlegroups .com>,
activearun...@gmail.com <activearun...@gmail.comwrote:
Can anyone give some idea about developing an 8085 simulator
program in C? What techniques can be handled to develop this?
-Personally-, I wouldn't bother unless it was an assignment or
a pet learning project (and even then, I'd reconsider whether
8085 was the right choice of processors.)
I don't think 8085 is such a bad choice.

It is if you want o buy one... I am certain the are obsolete these
days,.
Very simple instruction set.
I did this one weekend about 20 years ago just for the heck of it. I
had an old single board PC I wanted to emulate on a VAX.

Exactly....20 years ago It might be technically nice but getting the HW
is another matter. As for the tools.... i will dust of the compiler on
the 5.25" floppies.....
You can still get the Z80 at DigiKey. Same instruction set, even
easier to connect up (the address and data bus are not multiplexed
like on the 8085). But then the OP just wants to emulate it, not build
one (but I would suggest doing so anyway). And since he wants to do it
in C, if he has trouble along the way his questions will likely be on
topic for this group. As to the rest of this discussion...

Jun 5 '07 #7
ms*******@yahoo.com writes:
You can still get the Z80 at DigiKey. Same instruction set, even
easier to connect up (the address and data bus are not multiplexed
like on the 8085).
I think you are confusing 8080 and 8085.

--
Jean-Marc, who has programmed both but could be the one doing the confusion
Jun 5 '07 #8
On Jun 5, 11:28 am, Jean-Marc Bourguet <j...@bourguet.orgwrote:
mstork...@yahoo.com writes:
You can still get the Z80 at DigiKey. Same instruction set, even
easier to connect up (the address and data bus are not multiplexed
like on the 8085).

I think you are confusing 8080 and 8085.

--
Jean-Marc, who has programmed both but could be the one doing the confusion
Nope, the 8080 used an external clock generator (8224) and system
controller (8228) that were built into the 8085. There are a couple of
undefined opcodes in the 8080/8085 that the Z80 defined to extend the
architecture of the 8080/8085. It doubled the number of registers,
demuxed the IO, and added a few new registers. However, as long as you
don't use those undefined opcodes, it is 100% software compatible
(only the timing is different).

Jun 5 '07 #9
Ben Pfaff wrote:
>
ms*******@yahoo.com writes:
The OP wanted suggestions on techniques to do this. As I recall, the
upper nibble of the opcode pretty much tells you what the instruction
will do, so I made an array of 16 functions and used the upper nibble
to index into the array. Then I had 16 individual functions to handle
the operations. The lower nibble is mostly for addressing, so that too
can index into an array for the correct register. Setting the flags
properly was the trickiest part.

This sounds like a fun instruction set on which to practice
writing a (static or dynamic) binary translator. (Of course,
there's no way to actually run the translated code without
invoking undefined behavior, from a comp.lang.c point of view.)
How so? You have a struct holding the emulator's CPU registers, and a
64K unsigned char array (or two 32K arrays, since I seem to recall the
standard not requiring support for 64K arrays) representing the memory.

Now, emulating the hardware which might be surrounding the CPU is
another story. (Though you're probably more likely to run into
"implementation defined" or "unspecified" behavior than actual UB.)

:-)

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Jun 5 '07 #10
In article <46***************@spamcop.net>,
Kenneth Brody <ke******@spamcop.netwrote:
>Ben Pfaff wrote:
>This sounds like a fun instruction set on which to practice
writing a (static or dynamic) binary translator. (Of course,
there's no way to actually run the translated code without
invoking undefined behavior, from a comp.lang.c point of view.)
>How so? You have a struct holding the emulator's CPU registers, and a
64K unsigned char array (or two 32K arrays, since I seem to recall the
standard not requiring support for 64K arrays) representing the memory.
Ben is talking about binary *translator* -- i.e., that the 8085 binary
code be examined and converted to code native to the hosting system
and run directly as native code instead of by emulating each 8085
instruction. And he is correct that you can't actually run the
translated code without undefined behaviour, as C does not offer
any mechanism to compute native code and set that code into execution.

For example, C does *not* offer

unsigned char object_code[SomeSizeOrOther];
object_code[SomeLocationOrOther] = SomeNativeOpcodeOrOther;
((void(*)()) object_code)(); /* undefined behaviour! */

There is no C facility to convert an object pointer into a function
pointer.
--
Is there any thing whereof it may be said, See, this is new? It hath
been already of old time, which was before us. -- Ecclesiastes
Jun 5 '07 #11

<ms*******@yahoo.comwrote in message
news:11**********************@w5g2000hsg.googlegro ups.com...
On Jun 5, 11:28 am, Jean-Marc Bourguet <j...@bourguet.orgwrote:
>mstork...@yahoo.com writes:
You can still get the Z80 at DigiKey. Same instruction set, even
easier to connect up (the address and data bus are not multiplexed
like on the 8085).

I think you are confusing 8080 and 8085.

--
Jean-Marc, who has programmed both but could be the one doing the
confusion

Nope, the 8080 used an external clock generator (8224) and system
controller (8228) that were built into the 8085. There are a couple of
undefined opcodes in the 8080/8085 that the Z80 defined to extend the
architecture of the 8080/8085. It doubled the number of registers,
demuxed the IO, and added a few new registers. However, as long as you
don't use those undefined opcodes, it is 100% software compatible
(only the timing is different).
Oops, only 99.99% software compatible -- if you did an 8 bit add or
subtract, the 8080/8085 would save the parity of the result into the 'parity
flag', while the Z80 would save whether the operation overflowed into the
parity flag. That generally came up only if you were deliberately writing
code that would work differently on the different processors, but it is a
difference.

--
poncho
Jun 5 '07 #12
ms*******@yahoo.com wrote:
rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote:
>activearun...@gmail.com <activearun...@gmail.comwrote:
>> Can anyone give some idea about developing an 8085 simulator
program in C? What techniques can be handled to develop this?

-Personally-, I wouldn't bother unless it was an assignment or
a pet learning project (and even then, I'd reconsider whether
8085 was the right choice of processors.)

I don't think 8085 is such a bad choice. Very simple instruction set.
I did this one weekend about 20 years ago just for the heck of it. I
had an old single board PC I wanted to emulate on a VAX.

The OP wanted suggestions on techniques to do this. As I recall, the
upper nibble of the opcode pretty much tells you what the instruction
will do, so I made an array of 16 functions and used the upper nibble
to index into the array. Then I had 16 individual functions to handle
the operations. The lower nibble is mostly for addressing, so that too
can index into an array for the correct register. Setting the flags
properly was the trickiest part.
He is better off simulating the 8080 instruction set, which can
then be expanded into the Z80 set, which in turn can be expanded
into the 64180 set. The 8085 is a dead end.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jun 6 '07 #13
Walter Roberson wrote:
>
In article <46***************@spamcop.net>,
Kenneth Brody <ke******@spamcop.netwrote:
Ben Pfaff wrote:
This sounds like a fun instruction set on which to practice
writing a (static or dynamic) binary translator. (Of course,
there's no way to actually run the translated code without
invoking undefined behavior, from a comp.lang.c point of view.)
How so? You have a struct holding the emulator's CPU registers, and a
64K unsigned char array (or two 32K arrays, since I seem to recall the
standard not requiring support for 64K arrays) representing the memory.

Ben is talking about binary *translator* -- i.e., that the 8085 binary
code be examined and converted to code native to the hosting system
and run directly as native code instead of by emulating each 8085
instruction.
Ah. I was thinking "emulator" rather than "translator". Of
course, something that generates (portable) C source code which
is to be compiled elsewhere could qualify as a "translator".
And he is correct that you can't actually run the translated code
without undefined behaviour, as C does not offer any mechanism to
compute native code and set that code into execution.

For example, C does *not* offer

unsigned char object_code[SomeSizeOrOther];
object_code[SomeLocationOrOther] = SomeNativeOpcodeOrOther;
((void(*)()) object_code)(); /* undefined behaviour! */

There is no C facility to convert an object pointer into a function
pointer.
Is this actually UB, or is it "implementation defined"?

Also, isn't a compiler allowed to define the behavior which is UB
according to the standard? In other words, a compiler _could_
explicitly allow such a construct, with the caveat (of course)
that the pointer must point to valid machine code, to allow
things similar to Java's JIT[1] compiler.
[1] JIT == "Just In Time". As I understand it, the Java bytecode is
compiled into native machine code as the program runs.

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Jun 6 '07 #14
On Jun 5, 5:01 pm, CBFalconer <cbfalco...@yahoo.comwrote:
>
He is better off simulating the 8080 instruction set, which can
then be expanded into the Z80 set, which in turn can be expanded
into the 64180 set. The 8085 is a dead end.
I think you are confusing 8085 and 8086/8088.

Jun 6 '07 #15
ms*******@yahoo.com wrote:
CBFalconer <cbfalco...@yahoo.comwrote:
>>
He is better off simulating the 8080 instruction set, which can
then be expanded into the Z80 set, which in turn can be expanded
into the 64180 set. The 8085 is a dead end.

I think you are confusing 8085 and 8086/8088.
No, I am not. You are. You can also expand 8080 code into 8085
code, but that is the end.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jun 6 '07 #16

"Kenneth Brody" <ke******@spamcop.netwrote in message
news:46***************@spamcop.net...
Walter Roberson wrote:
>>
In article <46***************@spamcop.net>,
Kenneth Brody <ke******@spamcop.netwrote:
>Ben Pfaff wrote:
>This sounds like a fun instruction set on which to practice
writing a (static or dynamic) binary translator. (Of course,
there's no way to actually run the translated code without
invoking undefined behavior, from a comp.lang.c point of view.)
>How so? You have a struct holding the emulator's CPU registers, and a
64K unsigned char array (or two 32K arrays, since I seem to recall the
standard not requiring support for 64K arrays) representing the memory.

Ben is talking about binary *translator* -- i.e., that the 8085 binary
code be examined and converted to code native to the hosting system
and run directly as native code instead of by emulating each 8085
instruction.

Ah. I was thinking "emulator" rather than "translator". Of
course, something that generates (portable) C source code which
is to be compiled elsewhere could qualify as a "translator".
>And he is correct that you can't actually run the translated code
without undefined behaviour, as C does not offer any mechanism to
compute native code and set that code into execution.

For example, C does *not* offer

unsigned char object_code[SomeSizeOrOther];
object_code[SomeLocationOrOther] = SomeNativeOpcodeOrOther;
((void(*)()) object_code)(); /* undefined behaviour! */

There is no C facility to convert an object pointer into a function
pointer.

Is this actually UB, or is it "implementation defined"?
Undefined Behavior. "Implementation defined" means that the implementation
is required to document it, and the Standard places no such requirement.
>
Also, isn't a compiler allowed to define the behavior which is UB
according to the standard?
Of course. Undefined Behavior means the Standard places no requirements,
and so the implementation is free to do whatever it wants. If it wants to
define the behavior in a particular way, and additionally to document what
this behavior is, that's just fine.
In other words, a compiler _could_
explicitly allow such a construct, with the caveat (of course)
that the pointer must point to valid machine code, to allow
things similar to Java's JIT[1] compiler.
[1] JIT == "Just In Time". As I understand it, the Java bytecode is
compiled into native machine code as the program runs.

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>


Jun 6 '07 #17
<ms*******@yahoo.comwrote in message
news:11*********************@o5g2000hsb.googlegrou ps.com...
You can still get the Z80 at DigiKey. Same instruction set, even
easier to connect up (the address and data bus are not multiplexed
like on the 8085).
Not the same instruction set. The common denominator is the 8080. The Z80
adds a lot of new instructions. The 8085 added a few new instructions.
Some of those new ones for the 8085 use the same op-codes as new ones for
the Z80, but do entirely different things. There were also a few flags
which responded differently on the 8085 than they did on the 8080 or Z80.
When we wanted a single executable to run on two or three of these devices,
we used to write "detector code" which nudged at these flags and
instructions to figure out which machine the code was running on.

If one want's to use other processors "based" at 8080 there's also the
64180, the Z180 (Z80's with MMUs and a few other new features) and the
processor in the original Game Boy, which included some, but not all, of the
Z80 additional instructions and, as I recall, a few of it's own, and I seem
to remember an Intel 8080 or 8085 based CPU intended specifically for the
embedded market which had a few other additional instructions specifically
intended to cut down on external I/O hardware.

- Bill

Jun 7 '07 #18
Kenneth Brody wrote:
Walter Roberson wrote:
>>
For example, C does *not* offer

unsigned char object_code[SomeSizeOrOther];
object_code[SomeLocationOrOther] = SomeNativeOpcodeOrOther;
((void(*)()) object_code)(); /* undefined behaviour! */

There is no C facility to convert an object pointer into a function
pointer.

Is this actually UB, or is it "implementation defined"?
The C standard does not define the behaviour, therefor it is UB.
This does not preclude other standards (like POSIX), or the compiler
writers themselves to specify what behaviour will happen.

UB merely means that the C standard does not restrict the behaviour of
the construct. Therefor, you should not use such constructs in code
that must be portable to all possible C implementations, as you can't
know what the behaviour will be.

In practice do compilers also implement other standards, like POSIX, or
have people come to rely on certain behaviours which all may indicate a
certain behaviour for constructs that are UB under the C standard
alone.

Due to the topicality of this group, we only look to the C standard to
see what behaviour we will get, so we will mark thing as undesirable
(due to UB) which are fairly common in other environments.
>
Also, isn't a compiler allowed to define the behavior which is UB
according to the standard? In other words, a compiler _could_
explicitly allow such a construct, with the caveat (of course)
that the pointer must point to valid machine code, to allow
things similar to Java's JIT[1] compiler.
Yes, and other standards may even require that the compiler does so.

Bart v Ingen Schenau
--
a.c.l.l.c-c++ FAQ: http://www.comeaucomputing.com/learn/faq
c.l.c FAQ: http://www.eskimo.com/~scs/C-faq/top.html
c.l.c++ FAQ: http://www.parashift.com/c++-faq-lite/
Jun 7 '07 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Alex Vinokur | last post by:
C++ Simulator of a Universal Turing Machine can be downloaded at : * http://alexvn.freeservers.com/s1/utm.html * http://sourceforge.net/projects/turing-machine/ The program simulates a...
9
by: Milk | last post by:
Hi all, Can anyone help me to do this Question. Coz this is my first time study C++ language and my lecture want me to do this kind of program, i really don't have any ideal pls help me here...
61
by: /* frank */ | last post by:
I have to do a homework: make a CPU simulator using C language. I have a set of asm instructions so I have to write a program that should: - load .asm file - view .asm file - do a step by step...
0
by: SatishPasala | last post by:
Hi I am developing a Windows Mobile application. I want Visual Studio to use Palm Simulator to display the application. Now it is pointing to Default Simulator. I downloaded the Palm...
0
by: François | last post by:
Hi, My current job is to develop VoiceXML dialogs. The voice platform that we use provides neither a debugger nor a simulator, and each time I want to test a new dialog, I have to upload it on...
1
by: Ciko | last post by:
Was wondering how I could write a simple simulator (assembler CPU Z80). Thanks for any advice, link.
0
by: Killingkids | last post by:
hello, everyone...im facing a big problem in my final year project, hope that u all can help me solve the problem ... i was doing a mobile web application which enable student to check the college...
0
by: Killingkids | last post by:
hello, everyone...im facing a big problem in my final year project, hope that u all can help me solve the problem ... i was doing a mobile web application which enable student to check the college...
3
by: DanielJohnson | last post by:
I was wondering if anyblody can suggest me a network simulator written in python in which I can add on my own code and extend its functionality. I am looking for a simulator which will simualte...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.