6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 8:55 am

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Wed Aug 15, 2007 10:32 am 
Offline
User avatar

Joined: Fri Dec 12, 2003 7:22 am
Posts: 259
Location: Heerlen, NL
Hallo allemaal,


Various emulators I know, like VICE, are written in C. Does anyone know an emulator of a wellknown computer written in (Turbo) Pascal?

Thanks!

_________________
Code:
    ___
   / __|__
  / /  |_/     Groetjes, Ruud
  \ \__|_\
   \___|       URL: www.baltissen.org



Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jul 26, 2010 3:27 pm 
Offline

Joined: Mon Jul 26, 2010 3:10 pm
Posts: 4
groeten terug ...

as i remember, there are:

- El Dendo's ED64 from belgium
http://ed64.eldendo.be/
(Marc Dendooven)
- My Little Simulator - Mertkan Yildirimli but the link seems to be broken (or apparently withdrawn), i once tried to retrieve something but failed;
- 'Brotkästchen' a german emulator written in Pascal / Delphi, about 60 KB in size
- last but not least since April my janE6502 is in use. I beg your pardon for delayed answer ;-)

kind regards
steve


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Aug 06, 2010 1:11 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Yikes! That's the most unusual Pascal I've ever seen. Free Pascal does a reasonable job of line breaks and indentation, but I wonder if this is meant to be a de-obfuscation challenge?

Unfortunately it isn't accepted by either p2c or gpc. But, you mention it passes 100 of Wolfgang's tests, so that's very impressive. Does it fail any or was that the number you tried?

Edit: thanks for the pointer to Marc's ED64 site: that's a nice clear walkthrough of the construction of an emulator, with a free emulator as a bonus!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Aug 07, 2010 3:38 pm 
Offline

Joined: Mon Jul 26, 2010 3:10 pm
Posts: 4
Thank you for revising the emulator ..
BigEd wrote:
Yikes! That's the most unusual Pascal I've ever seen. Free Pascal does a reasonable job of line breaks and indentation, but I wonder if this is meant to be a de-obfuscation challenge?


Not intentionally ;-) i needed to re-use my old ancient eprom programmer on my windows based computer, but its operating software was 6502-based, it came from an apple II and has been translated so it could run on PET and C64. First, i thought it were possible to take Vice and simply add some specific code. But the version i tested, had a bug, it froze after half an hour ("sound buffer overflow"). additionally, i dont understand much of the C programming language, my skills are limited, so i decided to make my own emulator in Delphi/pascal. I was looking for some code at http://www.zophar.net/6502.html but almost all examples from there are written in C or BASIC. Additionally, source code of most emulators seems to exceed 40 KB , that means in order to understand such code, i must read and flip *many* pages. Because i'm a little impaired with respect to my eyesight, i made a challenge out of it to put everything onto one single page (72 lines with 80 characters each), so i had to think very much to get it condensed, and do less typewriting in front of monitor. thank you for your patience with missing indents ...

There is an older , more object oriented (and more faulty) version , too. Perhaps you might try it:
http://home.foni.net/~sjanda/u6502b_ver ... iented.pas

It contains much human-readable information, indents and commentaries in brackets.

In order to check it out, you need to have a variable containing the processor:
... uses u6502b...
var m6502: T6502b ; Start:WORD;
begin
m6502:=T6502b.create; {Initialization}
{put some opcode into memory , e.g. LDA #$55}
m6502.mr.mM[$1000]:= $A9;
m6502.mr.mM[$1001]:= $55;
{set JAM = true causes emulation to stop after a single step}
m6502.JM :=1;
Start:= $1000;
{invoke emulation in single step mode}
m6502.SYS(start,0);
...
Showmessage('Accumulator contains now:'+ InttoHex(m6502.mr.AC,2));
...
m6502.free;
end;

Quote:
Unfortunately it isn't accepted by either p2c or gpc. But, you mention it passes 100 of Wolfgang's tests, so that's very impressive. Does it fail any or was that the number you tried?

There are two files involved, a core 6502 emulator and a c64 emulator which uses it. The latter needs some Win32-specific stuff, but the first is kept pretty portable.

I tried to get gpc to work under Cygwin, but my HelloWorld (hello.pas) won't compile. It complains the file "as" were missing, but i don't know where to start. It seems that one needs a Gnu C Compiler in order to check out the pascal one :-(

P2C may not work because janE6502 makes heavy use of "sets" which are a very pascal-like feature. To my limited knowledge, C doesnt have sets. possibly you might want to translate them manually into structs, arrays (preferred) or something alike.

I tried more than hundred,but it was tedious work. Some of Wolfgang's tests are very C64-specific. BRK for example, doesnt work properly. And every test program has to be invoked manually, in direct mode via menu, because i didnt implement I/O trapping. None of the tests is able to load the next test via daisy chain; rather they complain a basic error (illegal quantity because of the floppy disk primary address "8") after each test because the Load command is missing. On the other hand, i saved almost 99% of code space , source and object code either.
Quote:
thanks for the pointer to Marc's ED64 site: that's a nice clear walkthrough of the construction of an emulator, with a free emulator as a bonus!

If you need an emulator which is able to detect time expensive loops and give control back to another program outside during waits, you might consider my program useful.
Code:
label_doomsday1; LDA PERIPHERAL_PORT
                 CMP #some_input_key
                BNE doomsday

In such cases, e.g. El Dendo's program (and many other) would use up 100% CPU Load. But i needed such an "idle" feature because i wish to limit programming times for an EPROM with a timing base from outside the emulated 6502 system.


Last edited by Steve__Jay on Sat Aug 07, 2010 3:56 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Aug 07, 2010 3:53 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Steve__Jay wrote:
Because i'm a little impaired with respect to my eyesight, i made a challenge out of it to put everything onto one single page (72 lines with 80 characters each), so i had to think very much to get it condensed, and do less typewriting in front of monitor.

Ah, that makes sense!

Steve__Jay wrote:
There is an older , more object oriented (and more faulty) version , too. Perhaps you might try it:
http://home.foni.net/~sjanda/6502b_ver0 ... iented.pas

It contains much human-readable information, indents and commentaries in brackets.

Thanks - that sounds interesting, I'd like to have a look. Unfortunately the link doesn't resolve.

Steve__Jay wrote:
I tried to get gpc to work under Cygwin, but my HelloWorld (hello.pas) won't compile. It complains the file "as" were missing, but i don't know where to start. It seems that one needs a Gnu C Compiler in order to check out the pascal one :-(

That's a fairly easy one - you need the 'binutils' package.

Steve__Jay wrote:
P2C may not work because janE6502 makes heavy use of "sets" which are a very pascal-like feature.

Actually, it hung, so something in the program wasn't understood - I tried some aggressive commenting out but didn't find a cause.

One or other of the tools I tried objected to taking the address of a packed array. Another felt it had to use some 64-bit arithmetic to calculate some expressions. Maybe not so surprising that different compilers find different things to complain about.

Steve__Jay wrote:
I tried more than hundred,but it was tedious work. Some of Wolfgang's tests are very C64-specific. BRK for example, doesnt work properly. And every test program has to be invoked manually, in direct mode via menu, because i didnt implement I/O trapping.

An heroic effort!

Steve__Jay wrote:
If you need an emulator which is able to detect time expensive loops and give control back to another program outside during waits, you might consider my program useful.
Code:
label_doomsday1; LDA PERIPHERAL_PORT
                 CMP #some_input_key
                BNE doomsday

In such cases, e.g. El Dendo's program (and many other) would use up 100% CPU Load.

Right - I found your same-branch detection code, and that seems like quite a neat solution. There was an uninitialised variable nearby spotted by one of the compilers I tried.

Cheers
Ed


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Aug 07, 2010 4:10 pm 
Offline

Joined: Mon Jul 26, 2010 3:10 pm
Posts: 4
BigEd wrote:
Ah, that makes sense!

:)
of course, i like very much to write small programs, too ...

BigEd wrote:
I'd like to have a look. Unfortunately the link doesn't resolve.


An "u" letter was missing, i edited my posting above, hope it will work now .. i would be glad to hear some feedback.

Quote:
That's a fairly easy one - you need the 'binutils' package.

Thank you much for that information ... i'm not very familiar with simulated Un*x stuff.... and they [binutils] have to match my version of cygwin , right?

Quote:
Actually, it hung, so something in the program wasn't understood - I tried some aggressive commenting out but didn't find a cause.

may i ask, did you try to compile the wholesale project file (C164.dpr or somthing like this), or the j6502.pas ?
Quote:
One or other of the tools I tried objected to taking the address of a packed array.

i fear, packed arrays will become deprecated one day ... some compilers seem to complain when fed with variant records also .. i use plenty of them ...

Quote:
Another felt it had to use some 64-bit arithmetic to calculate some expressions. Maybe not so surprising that different compilers find different things to complain about.

Thats true !
Quote:
An heroic effort!

thank you - but it needs less thinking and much more copy-pasting ;)

Quote:
Right - I found your same-branch detection code

This i consider to be a *really* heroic effort , to find such a piece of code in such an obfuscated text ;)

Quote:
There was an uninitialised variable nearby spotted by one of the compilers I tried.


Thanks for this information. Yes there are some variables not really needed, too. I inserted them in advance. Possibly some branch identification is not done perfectly well.

so long,
Steve


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Aug 07, 2010 4:44 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Steve__Jay wrote:
BigEd wrote:
I'd like to have a look. Unfortunately the link doesn't resolve.

An "u" letter was missing, i edited my posting above, hope it will work now .. i would be glad to hear some feedback.

Thanks - I see comments and indentation, as promised, which is a huge benefit!

Steve__Jay wrote:
Quote:
That's a fairly easy one - you need the 'binutils' package.

Thank you much for that information ... i'm not very familiar with simulated Un*x stuff.... and they [binutils] have to match my version of cygwin , right?

It's easiest to get hold of cygwin's own version by re-running the cygwin installer and selecting some extra packages (compared to downloading and building binutils from source.) The problem which arises is when a lot of time has passed and cygwin needs to update a lot of things too. For that reason, I try to load as much as I'm likely to need at the time of first installation, and then leave it alone.

But if you do build binutils from source, I don't think the version is very critical.

Steve__Jay wrote:
i fear, packed arrays will become deprecated one day ... some compilers seem to complain when fed with variant records also .. i use plenty of them ...

I saw the giant variant record - it looked scary to me. But if you're familiar with the technique and it works for you, fair enough.

Cheers
Ed


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Aug 07, 2010 7:33 pm 
Offline

Joined: Mon Jul 26, 2010 3:10 pm
Posts: 4
BigEd wrote:
I see comments and indentation, as promised, which is a huge benefit!
Thank you -it has never been intended to make someone suffer ...

Quote:
It's easiest to get hold of cygwin's own version by re-running the cygwin installer and selecting some extra packages (compared to downloading and building binutils from source.)

I will try this in a few moments and later edit my post, okay? to me, your proposal seems to be a good solution. (i have to fix several things, too.)

Quote:
The problem which arises is when a lot of time has passed and cygwin needs to update a lot of things too. For that reason, I try to load as much as I'm likely to need at the time of first installation, and then leave it alone.

I did similarly, but when i needed cygwin first, it was because of fontforge. It [cygwin] demanded hundreds of megabytes ... my quota almost ran short ... and i needed fontforge just in order to improve some C64-like CBM font for use with my emulator, so i forgot to install the binutils ..
Since now, I tried to avoid building up from scratch (source) ... it requires so much reading manpages ;-)

Quote:
I saw the giant variant record - it looked scary to me. But if you're familiar with the technique and it works for you, fair enough.

truth be told, i'm not very experienced, but it has been necessity - at least two overlapping variants are needed in order to make the memory (planned: 64 k) and the 'register file' appear to be the same chunk of memory. thus, by computing one single index, memory and registers can be treated interchangeably. E.g., LDA/STA instructions and TAX/TXA instructions altogether shrink to one single statement: q^:=p^
(this holds true for LDA and so on, and for the STA ones, i simply have to exchange pointers beforehand.)

kind regards..
Steve

EDIT /PS: Having read your postings above repeatedly, i should perhaps clarify that my machine is 32 bit. Due to delphi's Int64 type, i did not draw the conclusion that on some other modern computers, the generic type "integer" possibly denotes a 64 bit type while on mine it denotes 32 bit. Also, i switched off 'range checking' , i choose {$ALIGNMENT OFF} and 'short circuit evaluation on.'

Quote:
Actually, it hung, so something in the program wasn't understood - I tried some aggressive commenting out but didn't find a cause.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 08, 2010 8:14 am 
Offline
User avatar

Joined: Fri Dec 12, 2003 7:22 am
Posts: 259
Location: Heerlen, NL
Steve__Jay wrote:
- El Dendo's ED64 from belgium ......

Hartelijk dank !!! (Thank you very much)

I've been on holiday as well, therefore my late reply.

_________________
Code:
    ___
   / __|__
  / /  |_/     Groetjes, Ruud
  \ \__|_\
   \___|       URL: www.baltissen.org



Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 08, 2010 3:54 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Quote:
by computing one single index, memory and registers can be treated interchangeably. E.g., LDA/STA instructions and TAX/TXA instructions altogether shrink to one single statement: q^:=p^
(this holds true for LDA and so on, and for the STA ones, i simply have to exchange pointers beforehand.

nice!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Nov 06, 2010 4:49 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Steve__Jay wrote:
groeten terug ...

[snip]
- My Little Simulator - Mertkan Yildirimli but the link seems to be broken (or apparently withdrawn), i once tried to retrieve something but failed;
[snip]
kind regards
steve

I've received a private message telling us that My Little Simulator can be downloaded from http://www.mertkan.net - there's a *.rar archive with Delphi (Pascal) sources and a recently built windows executable. Free for non-commercial use.

It emulates a 6502 or 65816 but is not finished - decimal mode is declared as not working. There are some samples:
Code:
7segment2.asm  7segment.asm  leds.asm  steppermotor.asm  terminaltest.asm

which demonstrate use of the configurable peripherals.

I downloaded, unpacked, virus checked and ran the provided *.exe in Linux on Wine - it looks like this:
Attachment:
mylittlesimulator2.png
mylittlesimulator2.png [ 71.97 KiB | Viewed 2618 times ]


The trick is to open a New project, write some code then use the big tick (which is labelled disassemble) to assemble it, then the bug (insect) to go into simulation mode, at which point the run/step buttons become active.

Thanks to PM person!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 guests


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 post attachments in this forum

Search for:
Jump to: