Jump to content

david77

Members
  • Posts

    31
  • Joined

  • Last visited

david77's Achievements

Newbie

Newbie (1/7)

0

Reputation

  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()
×
×
  • Create New...