Announcement

Collapse

Forum Rules and Etiquette

Our mission ...

This forum is part of our mission to promote the preservation of vintage computers through education and outreach. (In real life we also run events and have a museum.) We encourage you to join us, participate, share your knowledge, and enjoy.

This forum has been around in this format for over 15 years. These rules and guidelines help us maintain a healthy and active community, and we moderate the forum to keep things on track. Please familiarize yourself with these rules and guidelines.


Rule 1: Remain civil and respectful

There are several hundred people who actively participate here. People come from all different backgrounds and will have different ways of seeing things. You will not agree with everything you read here. Back-and-forth discussions are fine but do not cross the line into rude or disrespectful behavior.

Conduct yourself as you would at any other place where people come together in person to discuss their hobby. If you wouldn't say something to somebody in person, then you probably should not be writing it here.

This should be obvious but, just in case: profanity, threats, slurs against any group (sexual, racial, gender, etc.) will not be tolerated.


Rule 2: Stay close to the original topic being discussed
  • If you are starting a new thread choose a reasonable sub-forum to start your thread. (If you choose incorrectly don't worry, we can fix that.)
  • If you are responding to a thread, stay on topic - the original poster was trying to achieve something. You can always start a new thread instead of potentially "hijacking" an existing thread.



Rule 3: Contribute something meaningful

To put things in engineering terms, we value a high signal to noise ratio. Coming here should not be a waste of time.
  • This is not a chat room. If you are taking less than 30 seconds to make a post then you are probably doing something wrong. A post should be on topic, clear, and contribute something meaningful to the discussion. If people read your posts and feel that their time as been wasted, they will stop reading your posts. Worse yet, they will stop visiting and we'll lose their experience and contributions.
  • Do not bump threads.
  • Do not "necro-post" unless you are following up to a specific person on a specific thread. And even then, that person may have moved on. Just start a new thread for your related topic.
  • Use the Private Message system for posts that are targeted at a specific person.


Rule 4: "PM Sent!" messages (or, how to use the Private Message system)

This forum has a private message feature that we want people to use for messages that are not of general interest to other members.

In short, if you are going to reply to a thread and that reply is targeted to a specific individual and not of interest to anybody else (either now or in the future) then send a private message instead.

Here are some obvious examples of when you should not reply to a thread and use the PM system instead:
  • "PM Sent!": Do not tell the rest of us that you sent a PM ... the forum software will tell the other person that they have a PM waiting.
  • "How much is shipping to ....": This is a very specific and directed question that is not of interest to anybody else.


Why do we have this policy? Sending a "PM Sent!" type message basically wastes everybody else's time by making them having to scroll past a post in a thread that looks to be updated, when the update is not meaningful. And the person you are sending the PM to will be notified by the forum software that they have a message waiting for them. Look up at the top near the right edge where it says 'Notifications' ... if you have a PM waiting, it will tell you there.

Rule 5: Copyright and other legal issues

We are here to discuss vintage computing, so discussing software, books, and other intellectual property that is on-topic is fine. We don't want people using these forums to discuss or enable copyright violations or other things that are against the law; whether you agree with the law or not is irrelevant. Do not use our resources for something that is legally or morally questionable.

Our discussions here generally fall under "fair use." Telling people how to pirate a software title is an example of something that is not allowable here.


Reporting problematic posts

If you see spam, a wildly off-topic post, or something abusive or illegal please report the thread by clicking on the "Report Post" icon. (It looks like an exclamation point in a triangle and it is available under every post.) This send a notification to all of the moderators, so somebody will see it and deal with it.

If you are unsure you may consider sending a private message to a moderator instead.


New user moderation

New users are directly moderated so that we can weed spammers out early. This means that for your first 10 posts you will have some delay before they are seen. We understand this can be disruptive to the flow of conversation and we try to keep up with our new user moderation duties to avoid undue inconvenience. Please do not make duplicate posts, extra posts to bump your post count, or ask the moderators to expedite this process; 10 moderated posts will go by quickly.

New users also have a smaller personal message inbox limit and are rate limited when sending PMs to other users.


Other suggestions
  • Use Google, books, or other definitive sources. There is a lot of information out there.
  • Don't make people guess at what you are trying to say; we are not mind readers. Be clear and concise.
  • Spelling and grammar are not rated, but they do make a post easier to read.
See more
See less

i4004 simulator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    i4004 simulator


    i4004sim.png
    Wrote a CPU simulator program. Hope the code is correct.
    http://g0blinish.ucoz.ru/pb2/i4004sim.zip

    #2
    Nice. Fun, isn't it?

    Comment


      #3
      Next is to instrument your simulator to run some code. An interesting piece of real code is to implement Tom Pittman's resident assembler. It requires at least 3 4002s and resides in 1K of 4004 code. It uses a TTY serial input and output stream. This requires both RAM output ports and ROM input ports. It would normally run on a SIM4-01, SIM4-02 or SIM4-03. Description of a SIM4-01 can be found on bitsavers, MCS4 Users Manual.
      Do note that this code depends on the proper 4004 stack operation. As a hint, the code will not run on a 4040 based machine. Tom also depends on the proper action of instructions like FIN and various, partial address, page fetching instructions to do the right thing on page boundaries.
      The TTY assumes a ASR33 running at 110 baud. It assumes that the source is on punch tape and it writes out the first pass and final binary on the punch tape. The binary is in BPNF format as described in the manual for submitted ROM images( also in data bit inversed as would be used be used, with a SIM4-01 and MP7-03, 1702A, programming setup ).
      I believe, if your simulator can properly run Tom's assembler, it is likely to be able to simulate any 4004 code.
      Dwight

      Comment


        #4
        why won't the code run? because of the wrong stack code?

        Comment


          #5
          The 4040 can nest 7 levels before overflowing, while the 4004 can only nest 3 levels before overflowing. Tom's code depends on the proper behavior on an overflow.
          Dwight

          Comment


            #6
            Yes, I was confused by the description of the stack, and many emulators use a different implementation of the stack

            Comment


              #7
              Not all the ones on the web will work right. There are 4 registers pointed to by the current PC. As is normal, the the next sequential address is place in that register pointed to by the current PC, the called address is place in the next register and the current PC point uses that new register.
              When the stack is over written and followed by code that does 4 BBL instructions, on the 4th BBL return, it will go to the address that was over written by the JMS call.
              Tom uses this to change the flow of the state of the program. Since the 4th JMS doesn't overwrite the return address on a 4040, the code, as written will not work on the 4040. Almost no one uses this difference between the two processors that I've seen. You have to remember, Tom wrote the assembler to fit into 1K of code space. He used just about every possible trick.
              There is one other funny behavior that I've seen used for both the 4004 and the 4040. The JCN has 8 possible actions based on the condition code. One of those is an "Always" jump that is redundant with the JUN but only on the same page. This is one of the funny page based difference if the code is at a page boundary. There is no advantage to using this instead of the JUN but a simulator must still do the right thing. The other rarely used variant is the "Never" jump. This is a tricky one. When I disassemble this one, I always use the additional instruction of SKIP to make the code more readable in the disassembly. The skipped address is often used for a single byte instruction, like LDM. This is often used at the beginning of a subroutine. This allows the subroutine to start with multiple possible values in the accumulator. The code might look like:
              ENTER1 LDM 5
              SKIP
              ENTER2 LDM 4
              ... do something with ACC
              BBL 0
              This allows the same subroutine to be used from multiple places that require 4 in some cases and 5 in others. It only makes sense if you have multiple times you need these different values, otherwise it one would use the LDM instruction before the call. I've seen this used in code that was used to run a printer.
              I hope this helps you get you simulator working correctly.
              You should probably make a input option for you simulator that would take either binary or BNPF code, with the option to use bit inversion. That way it could use Tom's assembler to create code to simulate.
              Making a simple way to instrument the assembler with I/O operations would enhance its use. Things like buttons for inputs and lights for outputs would be useful. Also adding the ability to add things that can be que'd up like serial data I/O, that is cycle count determined, would be useful, especially for something like Tom's code.
              You'd then have something that would be off more use than just executing a string of instructions.
              Dwight


              Comment


                #8
                One of the emulators' errors is the DAC code
                Code:
                void dac()
                {
                rega--;
                if (rega & ~15) fcarry = 1;
                else fcarry = 0;
                rega = rega & 15;
                } /* dac */
                I believe that the carry flag is defined incorrectly

                Comment


                  #9
                  Originally posted by dwesti View Post
                  Yes, I was confused by the description of the stack, and many emulators use a different implementation of the stack
                  Yea, there's nothing more fun than testing your simulator against one a "working one" that just happens to be wrong.

                  Comment


                    #10
                    Originally posted by whartung View Post

                    Yea, there's nothing more fun than testing your simulator against one a "working one" that just happens to be wrong.
                    I don't understand your sarcasm

                    Comment


                      #11
                      Originally posted by dwesti View Post
                      One of the emulators' errors is the DAC code
                      Code:
                      void dac()
                      {
                      rega--;
                      if (rega & ~15) fcarry = 1;
                      else fcarry = 0;
                      rega = rega & 15;
                      } /* dac */
                      I believe that the carry flag is defined incorrectly
                      It is not clear what the size of reg is in bits but assuming it is at lest a byte size,
                      only 0 should should not set a carry. All other numbers, 1 to 15, inclusive, should create a carry.
                      I would say the code fails.
                      Dwight

                      Comment


                        #12
                        According to MCS-4_Assembly_Language_Programming_Manual_Dec73.pdf
                        Code:
                        ; 1001
                        ; 1111 -1
                        ; 11000 cy=1 no borrow
                        
                        ; 0000
                        ; 1111
                        ; 01111 cy=0 borrow
                        Last edited by dwesti; October 16, 2021, 08:42 PM. Reason: mistype

                        Comment


                          #13
                          Didn't know where else to put this. Does anyone recognize this 4040 board?
                          Sadly, the 0K EPROM is all FFs

                          Microcomputer_CPU-4.jpg

                          Comment


                            #14
                            Hi Al
                            I don't recognize it. It is clearly a controller card for something. It might be a version of one of the Prolog 4040 boards but I don't think so. Sometimes a dump of the EPROMs will give some indication. I decoded some EPROMs for a friend that had a Prolog 4004 board. It was clearly use as a printer control. I forget which but one of the printer companies used the Prolog boards.
                            I'd suspect the DM8898 is used for input? It might be something like a BCD thumb wheel switch or something, assuming it is wired as an input. The wiring configuration might give a clue. The 3404s are output latches. It was likely made in a narrow range of time. The 4289 and the 4201 together were only made for a short time. the 4201 was soon replaced by the 4201A and the 4289 replaced the 4008/9 chipset.
                            ​​​​​​​I'd be curious to see the backside wring?
                            Dwight

                            Comment


                              #15
                              here is the 1K rom and the back side
                              1K.png
                              Microcomputer_CPU-4_b.jpg

                              Comment

                              Working...
                              X