Jump to content

david77

Members
  • Posts

    31
  • Joined

  • Last visited

Everything posted by david77

  1. I'm not a programmer and I'm not going to learn a new language at my age.My traffic lights work without subroutines- see http://homepage.ntlworld.com/stonebanks/cpuandtraffic2.htm Click on N2, paste to CPU, then click on S (slow) I'm going to try Dart - it's Javascript with optional types. I suspect it will be a lot of work to knock the assembler and CPU progs into shape, but I'll have a go.Thanks for all of your comments.
  2. [10/06/2012 21:06:13] JavaScript - file://localhost/C:/Documents%20and%20Settings/Computer/My%20Documents/SVGexamples/cpu18.svgEvent thread: clickUncaught exception: TypeError: Cannot convert 'n' to objectError thrown at line 432, column 0 in hexstr(n) in file://localhost/C:/Documents%20and%20Settings/Computer/My%20Documents/SVGexamples/cpu18.svg: s = n.toString(16).toUpperCase();function hexstr(n) // was hexfn6(n) // 6 i/p 0-255, return 2 char hex string{ var s = "";settext("screen3", n); // this reports that n is undefineds = n.toString(16).toUpperCase(); s=trim(s); if (s.length < 2) {s = "0" + s;} if (n==0) {s="00";} return s;}called from line 877, column 13 in showmem2(n, m) in file://localhost/C:/Documents%20and%20Settings/Computer/My%20Documents/SVGexamples/cpu18.svg: b=hexstr(mem[n]);function showmem2(n,m) {var a, b;a=hexstr(n); b=hexstr(mem[n]); settext(m,a+": "+; // a is the address, b is the content}called from line 882, column 17 in showmem(n) in file://localhost/C:/Documents%20and%20Settings/Computer/My%20Documents/SVGexamples/cpu18.svg: showmem2(n+1,"a2"); function showmem(n) { // this shows address and content of 'memory' on screen - the first locn is 61hex, then 99 and onwardsmemfirst = n;showmem2(n,"a1");showmem2(n+1,"a2");showmem2(n+2,"a3");showmem2(n+3,"a4");showmem2(n+4,"a5");showmem2(n+5,"a6");showmem2(n+6,"a7");showmem2(n+7,"a8");showmem2(n+8,"a9");showmem2(n+9,"a10");showmem2(n+10,"a11");showmem2(n+11,"a12");showmem2(n+12,"a13");showmem2(n+13,"a14");showmem2(n+14,"a15");showmem2(n+15,"a16");showmem2(n+16,"b1");showmem2(n+17,"b2");showmem2(n+18,"b3");showmem2(n+19,"b4");showmem2(n+20,"b5");showmem2(n+21,"b6");showmem2(n+22,"b7");showmem2(n+23,"b8");showmem2(n+24,"b9");showmem2(n+25,"b10");showmem2(n+26,"b11");showmem2(n+27,"b12");showmem2(n+28,"b13");showmem2(n+29,"b14");showmem2(n+30,"b15");showmem2(n+31,"b16");memlast = n+31;}called from line 797, column 53 in ex2(ch) in file://localhost/C:/Documents%20and%20Settings/Computer/My%20Documents/SVGexamples/cpu18.svg: showmem(abusval); // ex(2) executes the microcode steps case "L": mcodetxt="PC to Addr"; abusval=PC; showaddr(abusval); setcolor("PC2addr","red"); setcolor("Abus","red"); break; // PC and the addr are showing 3Dcalled from line 1002, column 4 in fnmcode() in file://localhost/C:/Documents%20and%20Settings/Computer/My%20Documents/SVGexamples/cpu18.svg: ex2(ch);function fnmcode() { // execute one microcode step and is called when button 'M' is clickedhexIR=IR.toString(16);hexIR = parseInt(hexIR, 16);var s=mc[hexIR]; // s is the microcode string shown below IR on screenvar ch;if (!f2) {fetch(true); f2=true; s=mc[hexIR]; mcodestep=0; settext("showmc",s); settext("showmc2","fetch");} else { if (mcodestep==0) { resetcolors(); } settext("showmc",mc[hexIR]); if (mcodestep<s.length) { ch=s[mcodestep]; ex2(ch); settext("showmc2",mcodestep.toString()+" "+ch+": "+mcodetxt); if (ch=="z") { f2=false; } else { mcodestep++; } } } return ch;} fnmcode executes one microcode stepex2 is called to run thru the code for a step. "L" PC to Addr seems to be the cause of the troubleshowmem and showmem2 simply show the content of memory accessedhexstr returns the address and content of a memory locn (with 2 calls)I would be grateful for any clue where to look. Thanks
  3. Ingolme is right when he says that I don't know what I am doing. I don't claim to be a programmer but I have done a bit of programming over the years. I had one of the first BBC micros many years ago so have used BASIC, Pascal, and am now struggling with Javascript. MY CGT program at http://homepage.ntlworld.com/stonebanks/0809tax28.htm has over 1000 lines of code and has been in use for several years. I'm quite proud of it although someone did say that it was written by a crap programmer when I asked for advice on another website. I did sell my Pascal model computer program to RAF Cosworth as a training aid and to a couple of other colleges, but I spent more on advertising than I received in sales so didn't make my fortune there. I now want to put the program onto the web. I do not have any access to server-side programs. If I want to get this working on-line, then it will have to be in a language that runs on a user's browser, and that means Javascript. If this was Pascal, I'd declare memory to be an array of 256 bytes. In JS it is declared as an array of whatever type JS wants to make it - yuk. Yesterday, I wanted to use the Opera Dranonfly debugger but it wouldn't let me load the CPU program from child.htm so I wrote it into the CPU prog mem[0] = 0x3D; mem[1]=0x99; etc It looked ok on screen but then did its own thing when I tried to execute one micro-code step at a time - that's when I wrote my intemperate post above. Today, I have written the CPU machine-code program into the CPU JS code as text mem[0] = "3D"; mem[1]="99"; etc. That looks ok on screen and works until the fetch after the RET. Dragonfly told me an hour ago (but won't tell me now) that it couldn't convert 'n' in mem[n] to an object. I suspect that n is text. It seems to have returned zero so PC got loaded with the content of mem[0] which is 3D instead 06 which should have been the address following the CALL. The sun is shining now so I'll go and do something outside. I'll give this some more thought later. Thanks to both of you for your advice
  4. Javascript really is crap. Apologies for being rude, but it was easier to write these programs originally in Turbo Pascal than it is now to simply change the code for another language - and the reason is type. With Pascal, a programmer specifies that a variable is a string or an integer or whatever. Both the programmer and the compiler know what they are doing. I wanted to use Opera's Dragonfly to see what is going on with my CPU. RET appears to work correctly, but PC gets set to some strange value during the following fetch operation. At present, a program is written into memory from child.htm page but Dragonfly then wants the page reloaded which destroys the recently loaded program. So I wrote the computer code into the CPU memory as part of the CPU javasript code. The first instruction is MOV SP,99 - that puts 99hex into the Stack Pointer for a CALL return address. If running a program loaded by child.htm, it does what I want. Write the same thing into memory with code as part of my CPU and the memory displayed on screen looks correct, but it writes 153 into SP .... 153 = 9x16 + 9. So what am I seeing in memory on screen? Is it decimal, is it hex, or is it a string? I would know with Pascal, I haven't a clue with Javascript. I received an email recently http://www.i-program...s/167/4320.html most of which went over my head - in which Anders Hejlsberg, who brought us Turbo Pascal, Delphi and C#, not to mention the whole idea of .NET says "...a new cross platform language called JavaScript and the typesystem went out with the bath water. Now we can all wonder how we do medium to large scale development. Erik Meijer: "...Are you saying you cannot write large programs in JavaScript?" Anders Hejlsberg: "No, I think you can, but I don't think you can maintain them." The laughter at this point is telling of the opinion and attitude of the audience and the panel. Anders Hejlsberg: "... I tried a refactor in a big JavaScript program. Is this x the same as this x over there? I'm afraid I couldn't tell you." From here the discussion goes on to explain that this is the reason Google is creating Dart: Gilad Bracha: "...you can write them (large JavaScript programs) but after that you will be suitably punished." Erik Meijer: ".. but if you look at JavaScript it was defined independently of HTML" Gilad Bracha: "That's true but combining two bad things does not make them better. ".
  5. Ingholme - I've created another bit of microcode which calls memread2. The original memread works when reading immediate data as part of an instruction and memread2 which includes your code at #4 when reading mem addressed by B reg. I don't understand why I need to have different memread routines, but both of the programs loaded with N1 and N2 work now. Thanks
  6. What does "Warn Status" mean under my name on the left?
  7. I have an assembler program at http://homepage.ntlworld.com/stonebanks/asm5.htm which translates assembler mnemonics to machine codes. The instruction set and microcodes as shown at http://homepage.ntlworld.com/stonebanks/showmicrocode2.htm Clicking H shows two progs on N1 and N2.N1 is a simple INC in a loop copying from A to B reg. This works correctly from 00 to FF.N2 writes 10 to mem location 19 (correctly) and then reads it back - and gets 16. It then writes 20 to mem 19, and reads back 32. It then writes 30 and reads back 48. My problem is that the microcode step 'a' shown at #3 is the same step used for fetching the immediate data 10 correctly when mem is addressed by PC reg but gets it wrong when mem is addressed by B reg. I think that I'll have to create another microcode step that works when mem is addressed by B reg - but it's strange that the same code function memread(addr) gives different results depending on where the address comes from.
  8. function hexstr2(n) {var hD="0123456789ABCDEF";var h = hD.substr(n&15,1);n>>=4;h=hD.substr(n&15,1)+h;return h;} function showdata(dbusval) { // this writes the data to CPU imagevar s=hexstr2(dbusval);n=parseInt(s,16);var s= "Data "+ s + " "+ mybin(n);settext("dataval",s);} function memread(addr) { // this gets called by microcode step 'a'dbusval=mem[addr];dbusval=parseInt(dbusval, 16);showdata(dbusval);return dbusval;} case "a": mcodetxt="Memread";dbusval=memread(abusval); // dbusval = value on databus, abusval = value on address bussetcolor("dbus","red");setcolor("arrowin","red");if ((abusval < memfirst) || (abusval > memlast)) {showmem(abusval);}break; I want it to display in hex. It seems to work as an instruction operand (MOV A,10) but not with MOV A,( B ) which uses the same call.
  9. I've got some of my CPU working. I have provided details of the current problem onhttp://homepage.ntlw...s/modelinfo.htm I am having difficulty persuading javascript to handle hex data consistently. MOV A,10 puts 10hex into the A regand MOV ( ,A writes that to memory addressed by B - correctly. MOV A,( should read that back, but it gets 16. MOV A,10 uses 'memread' to read from memory (ok) while MOV A,( uses the same 'memread' code and gets it wrong. Any clues on where to look please? ( should be ( B ) without the spaces.
  10. My next problem is getting the cpu to write to the traffic lights. When I was getting the traffic lights to work, I had test buttons to call function fnportone(opcount) or fnporttwo(opcount) to change the lights. If you click on N to load a new prog, a child.htm page comes up with a preloaded simple prog. Clicking on Paste to cpu on the child page calls window.opener.storeprog(s); in the child page to store the prog in CPU memory. I was hoping to do something like that from the cpu to call the traffic functions.
  11. I have downloaded that SVG viewer. IE8 displays the images but I can't get fnlights() in the cpu to toggle the traffic light. Thanks again.
  12. I fear that you are right, dsonesuk. IE8 displays the CPU and Traffic light images, but it looks as tho I can't get the cpu to control the lights. I will detect IE8 and show an alert: "Sorry - my prog doesn't display with that browser. Try Opera, Firefox, or Chrome." Thanks again.
  13. Thanks dsonesuk - parent works with Chrome, Opera, and Firefox. IE8 reports Access is denied. line 794, column 0. 794 is the next blank line after the closing bracket of fnlights()
  14. Can someone please explain this to me from http://www.w3schools...ntentwindow.asp What is x?What is y?What does "if (y.document)y=y.document;" mean? function changeStyle(){var x=document.getElementById("myframe");var y=(x.contentWindow || x.contentDocument);if (y.document)y=y.document;y.body.style.backgroundColor="#0000ff";} fnlights() is called by clicking on the L button of my 'cpu' on http://homepage.ntlw...andtraffic2.htm function fnlights() {var lite, attrgoslow=false;var doc=top.document.getElementById("trafficdoc");var obj=(doc.contentWindow || doc.contentDocument);if (obj.document) obj=obj.document;lite = obj.getElementById("x1red");attr = lite.getAttribute("fill");if (attr == "red") { lite.setAttribute("fill", "black"); }else { lite.setAttribute("fill", "red"); }} This should toggle the top left red light. It works on Opera and Firefox but not on IE8 or Chrome browsers. Advice much appreciated, thanks Bring back Pascal, all is forgiven!
  15. Thanks for help so far. I've now got the CPU working slowly (although not fully tested). I now want the CPU to control the traffic lights. I have a parent page cpuandtraffic3.htm which is simply: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <html><head><title>CPU and Traffic Lights</title></head> <frameset cols="50%, 50%"><frame src="cpu14.svg" align="top" name="cpudoc"><frame src="traffic14.svg" align="top" name="trafficdoc"></frameset> </html> My CPU fnlights() code is triggered by onclick on the 'L' button function fnlights() {var lite, attrgoslow=false;var traffic = parent.document.getElementById('trafficdoc');var doc = traffic.document;lite = doc.getElementById("x1red");attr = lite.getAttribute("fill");if (attr == "red") { x1red.setAttribute("fill", "black"); }else { x1red.setAttribute("fill", "red"); }} and I am trying to change the colour of the traffic light<circle id="x1red" cx="175" cy="200" r="10" fill="red"/> Thanks for any advice. I should have added - Opera reports Event thread: clickUncaught exception: TypeError: Cannot convert 'traffic' to objectError thrown at line 780, column 0 in fnlights() in file://localhost/C:/Documents%20and%20Settings/Computer/My%20Documents/SVGexamples/cpu14.svg:var doc = traffic.document;
  16. I am now trying to get my CPU working on the web - see http://homepage.ntlworld.com/stonebanks/cpu14.svgClick N (new prog) will bring up a page with a bit of machine code. Click on the bottom of that page to paste into memory. M - executes one microcode step, and T (trace) executes a full CPU instruction.I would like S (slow) to call the trace function until stopped by clicking any button except T, S, or G (go - not yet working).function fntrace(){ // this executes one instruction until the microcode is "z"var ch, done=false;ch = fnmcode();if (ch=="z") {done = true;} else {setTimeout("done=fntrace()", 200);}settext("screen3", "done="+done); // just to see what's happening return done; }function fnslow(){goslow=true;var done = false;done = fntrace();if (done) {setTimeout("done=fntrace()", 200);}}Can someone please help?
  17. Thanks JustSomeGuy for your post #15 about getting data from a popup window to the parent - I've got that working. The two images cpu14.svg and traffic14.svg are embedded in a simple HTML table in cpuandtraffic.htm with links to those at the bottom of www.stonebanks.co.uk I now need a way to get a CPU OUT instruction to change the traffic lights, and for traffic sensors and wait button to be read by a CPU IN instruction. I used a table to get the two images side-by-side. The two images and javascript codes are id="cpu" and id="traffic" I'm hoping that those ids will help to get the two bits talking to each other. I would appreciate any advice please. If I get this working then I will then try getting an assembler working in javascript. Thanks for any help.
  18. It was the first line. I had opened it with viewBox="0 0 1250 710" I have changed that to be the same as the CPU page viewBox="0 0 625 710"
  19. I guess there's something wrong with my traffic lights page - it's too small however the two are put together: http://homepage.ntlworld.com/stonebanks/trafficandcpu.htm http://homepage.ntlworld.com/stonebanks/trafficandtraffic.htm
  20. I have now got some of my CPU working and I have tried to put it on a page with the traffic lights. However, the CPU is full-size but the traffic lights image is about half-size. They should both be the same size, and they are if viewed separatelyhttp://homepage.ntlworld.com/stonebanks/cpu11.svgand http://homepage.ntlworld.com/stonebanks/traffic12.svg The CPU image is centered wile the traffic lights are on the left. I don't understand that. They should both be the same. If I put two CPUs side by side in a table, the CPUs are both full sizesee http://homepage.ntlworld.com/stonebanks/cpuandcpu.htm Originally, the traffic lights were on the right-hand side of the page with x co-ordinates in the 600 to 1200 range. I have amended the x co-ordinates for traffic12.svg to be in the range 0 to 600, the same as the CPU, but the traffic lghts image is smaller then that of the CPU when put together see http://homepage.ntlworld.com/stonebanks/cpuandtraffic.htm Can anyone please suggest why?
  21. The latest traffic lights: http://homepage.ntlworld.com/stonebanks/traffic11.svg and cpu http://homepage.ntlworld.com/stonebanks/cpu6.svg I have some of my cpu working but I need a way to read a user's machine-code text input into array mem[].I tried a pop-up window with an input text box, but how do I get the data from the pop-up window to my svg mem[] array? Any suggestions, please?
  22. I had 3 'drivers' (2 processors and a BASIC interpreter) and half a dozen models. Putting that lot in a single file would make it massive. I only one bit of code for each item, so can I have an html page to select which one? So can I link driver1+model1 on one page, driver1+model2 on one page but without modifying the driver1 code? I don't mind a copy and paste to create a page, but I don't want several copies of the same code. Can I do it? cpu1cpu1+digital i/ocpu1+seven segment display... RISC RISC + digital i/oRISK + seven segment display... BASIC interpreterBASIC + model 1BASIC + model 2etc.
×
×
  • Create New...