%!PS % First Attempt at Machine Language Cookbook % ==================================================== % by Don Lancaster GG #116 FADESCUF.PSL % Copyright c 2010 by Don Lancaster & Synergetics, Box 809, Thatcher, AZ, 85552 % (928) 428-4073 Email: don@tinaja.com Website: http://www.tinaja.com % Consulting services available http://www.tinaja.com/info01.html % Linking welcome. Reposting expressly forbidden. % All commercial rights and all electronic media rights ~fully~ reserved. % Linking usually welcome. Reposting expressly forbidden. Version 1.1 % IMPORTANT NOTE: Don Lancaster's file gonzo.ps is required for this program. % After obvious location mods, uncomment ONE of the following two lines: (C:\\Documents and Settings\\don\\Desktop\\gonzo\\gonzo.ps) run % use internal gonzo % (A:\\gonzo.ps) run % use external gonzo % NOTE THAT ALL PS FILENAME STRINGS !!!DEMAND!!! DOUBLE REVERSE SLASHES. % GONZO20A Guru Gonzo PostScript power tools (Interim release) % Includes gonzo justification and layout utilities. % Copyright c 1990, 1996, 2001 by Don Lancaster and Synergetics, Box 809, % Thatcher Arizona, 5552 (928) 428-4073 don@tinaja.com support % via http://www.tinaja.com All commercial rights and all electronic % media rights **FULLY** reserved. Reposting is expressly forbidden. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% links menu directory %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This code locks pdfmark commands out of a PostScript printer. /pdfmark where {pop}{userdict /pdfmark /cleartomark load put} ifelse % /surl "start url" marks the beginning of a text sequence to be urled. % It also paints the text blue... /surl {mark /blue cvx 0.33 /setgray cvx % change text to blue /currentpoint cvx % remember box start /urly /exch cvx /store cvx /urlx /exch cvx /store cvx ] cvx % complete deferred command printlist exch 3 index exch put % stuff into gonzo printlist exch 1 add exch % increment gonzo list count } def % /eurl "end url" unmarks the end of a text sequence and sets up % the pdfmark needed to define the Acrobat web link. /eurl {mark % start deferred proc exch % position url string % /black cvx 0 /setgray cvx % turn blue marker off % maintextcolor /setrgbcolor cvx % reset to main text color??? /aqua cvx /black cvx /makeurl cvx % defer call of url builder ] cvx % complete deferred proc printlist exch 3 index exch % stuff into gonzo printlist put exch 1 add exch % increment gonzo list count } def % /makeurl generates the pdfmark, receiving a {(urlstring) makeurl}. % Note that it is not called until formatted printlist time... /urlover 0.2 def % fraction of hot area over bounds /makeurl { /cururlname exch store % save the url string mark % start pdfmark currentfont /ScaleMatrix get 3 get /fsize exch store % guess height /Rect [ urlx fsize urlover mul sub % set box left x urly fsize urlover mul sub % set box left y currentpoint exch fsize urlover mul add exch fsize add ] /Border [ 0 0 0] % [0 0 0 ] = none; [0 0 2] = debug /Color [ .7 0 0 ] /Action <> /Subtype /Link /ANN % annotation type pdfmark % call pdf operators } def % /makeurlx generates the box specific pdfmark, receiving % a {(urlstring) makeurl}. % Note that it is not called until formatted printlist time... /makeurlx { /cururlnamex exch store % save the url string mark % start pdfmark /Rect [ xpos % set box left x ypos 0.9 sub % set box left y xpos 2.8 add % box right x ypos 0.9 sub 2.8 add % box right y ] /Border [ 0 0 0] % [0 0 0 ] = none; [0 0 2] = debug /Color [ .7 0 0 ] /Action <> /Subtype /Link /ANN % annotation type pdfmark % call pdf operators } def /maintextcolor {0 0 0 } def % text link specific data -- use dictionary instead below % zzzz keep for search marker % dictionary method << % entered during gg116 /ebksamp1.asp (http://www.tinaja.com/ebksamp1.asp) /tvtcb.pdf (http://www.tinaja.com/ebooks/tvtcb.pdf) /unhalf.pdf (http://www.tinaja.com/glib/unhalf.pdf) >> {mark exch /eurl cvx ] cvx def} forall %%%%%%%%%%% tints to replace italic fonts %%%%%%%%%%%%% /to {tinton1 font6} store /tx {tintoff font1} store /tinton1 {mark 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tintoff {mark 0 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def %%%%%%%%%%%%%%%% jpg image and link %%%%%%%%%%%%%%%%%% % combined autopos jpeg conversion and hotlink: /jpegimageprocwithlink { % hoffset voffset hres vres save /snap2 exch def /infilename exch store % grab passed pix file /inurllink exch store % grab link filename /photoscale exch store /vpixels exch store /hpixels exch store translate % adjust position for final figure ??? inurllink setareaurl % autolink sizing /DeviceRGB setcolorspace % pick color model 0 0 translate % set page position hpixels vpixels scale % magnify unit square photoscale dup scale /infile infilename (r) file def % establish input read file /Data {infile /DCTDecode filter} def % define a data source << % start image dicationary /ImageType 1 % always one /Width hpixels % JPEG width in pixels /Height vpixels % JPEG height in pixels /ImageMatrix [hpixels 0 0 vpixels neg 0 vpixels ] /DataSource Data % proc to get filtered JPEG /BitsPerComponent 8 % color resolution /Decode [0 1 0 1 0 1] % per red book 4.10 >> image % call the image operator ypos snap2 restore /ypos exch def } def /setareaurl { % for auto include routine /cururlname exch store mark % start pdfmark /Rect [ 0 0 hpixels photoscale mul vpixels photoscale mul ] /Border [ 0 0 0] % [0 0 0 ] = none; [0 0 2] = debug /Color [ .7 0 0 ] /Action <> /Subtype /Link /ANN % annotation type pdfmark % call pdf operators } def /autoimageandlink1 {save /af1 exch store xpos ypos yinc add translate 0 0 2145 1617 .016 % xpos ypos xres yres pixscale (http://www.tinaja.com/images/newgor02.pdf) % url firs (C:\\Documents and Settings\\don 2\\Desktop\\rework mlc1\\gonzo\\newgor1a.jpg) jpegimageprocwithlink af1 restore} store /autoimageandlink2 {save /af1 exch store xpos ypos yinc add translate 0 0 2480 2480 .015 % xpos ypos xres yres pixscale (http://www.tinaja.com/images/pobox1.11.jpg) % url first (C:\\Documents and Settings\\don 2\\Desktop\\rework mlc1\\gonzo\\pobox1.11.jpg) jpegimageprocwithlink af1 restore} store %%%%%%%%%%%%%% reset size to book page %%%%%%%%%%%%%%%%%%%%% /setupshow { /pdfmark where {pop}{userdict /pdfmark /cleartomark load put} ifelse [/CropBox [0 0 5.25 74 mul 8.5 72 mul ] % set the wierd size /PAGES pdfmark [ {Catalog} << /ViewerPreferences << /FitWindow true /CenterWindow true >> /PageLayout /SinglePage % no rolling /Pagemode /FullScreen % fullscreen if not on web /View [/XYZ null null 1 ] % force 100% >> /PUT pdfmark } store %%%%%%%%%%%%%%%% book specific routines here %%%%%%%%%%%%%% /inches {72 mul} store /setuppage { 38 35 7.2 setgrid % 42 70 showgrid /base {2 yinc mul} store /lines {1 sub txtyinc mul base add} store /kern 0.1 store /txtwide 42 store } store /settextparams { /leftmargin 0 store /pm 2 store /txtyinc 1.56 store /yinc txtyinc store /kern 0.1 store /cstretch 0 store /sstretch 0 store /font1 /StoneSans [1.38 0 0 1.25 0 0 ] gonzofont font1 /font6 /StoneSans-Bold [1.38 0 0 1.25 0 0 ] gonzofont font6 font1 % must be font6 for /to } store /showrightpagenumber {/curnum exch store /font3 /MyriadPro-Bold 1.3 gonzofont font3 /rightmargin txtwide store rightmargin 0 curnum cr } store /showleftpagenumber {/curnum exch store /font3 /MyriadPro-Bold 1.3 gonzofont font3 0 0 curnum cl } store /setchapttitparams { /font0 /MyriadPro-Bold [3 0 0 2.4 0 0 ]gonzofont /tityinc 2.5 store font0 /xcen {txtwide 2 div} store /yinc tityinc store } store /setchapnumparams {} store % not yet needed /setoldgraybox {save /ogbsnap1 exch store /gtxt exch store /yposin exch store /xposin exch store /rawlinecount exch store /yinc 1.6 store /txtwide 30 store /pm -4 store /tbmargin 1 store % in line units /lrmargin 1.7 store /font4 /StoneSans-Bold 1.2 gonzofont /font5 /StoneSans 1.2 gonzofont font5 xposin yposin rawlinecount tbmargin 2 mul add yinc mul sub translate 0 0 mt rawlinecount tbmargin 2 mul add yinc mul pu txtwide lrmargin 2 mul add pr rawlinecount tbmargin 2 mul add yinc mul pd closepath gsave 0.8 1 1 setrgbcolor fill grestore 0.2 1 1 setrgbcolor 0.3 setlinewidth stroke black /txtwide txtwide pm add store lrmargin pm neg add rawlinecount 1 sub tbmargin add yinc mul 0.3 add gtxt cf ogbsnap1 restore } store %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%% book specific page data here %%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % reminders /274 is elipsis /320 is emdash /261 is endash /267 is bullet save /page1snap exch store setupshow setuppage black (|39) showrightpagenumber settextparams black 0 11 lines (|p|y |1Have you ever been behind the scenes in a post office? There are lots of similiarities between what goes on there and what happens inside a typical microcomputer.\nOur postmaster acts the same way a micro's CPU does when it decides what mail goes where. Large banks of boxes are available where users can go to pick up their mail. Any particular box might be for a family, for a business, for a club, or for a church, just as any particular location in a micro's address space can have various uses. These locations can be used for temporary or permanent storage of data and programs, or they can let you input or output to the real world.) cf setchapttitparams xcen 31.7 lines % /yinc tityinc store (A|kddresses and A|kddress\nSpaces) cc setchapnumparams xcen 38.4 lines (|3\320 SIX \320) cc 12 26 lines % 8 2 lines 4.5 19.2 (|/autoimageandlink1 ) cl showpage page1snap restore %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% save /page2snap exch store setupshow setuppage settextparams 0 44 lines (|p|y |1Some post office boxes may be empty or unrented. Others may be seldom used. Yet others will be very busy and may even over- flow if they aren't continuously emptied. In the same way, some locations in a micro's address space will be extremely busy, while others will not be used at all or may rarely see any action. The rules at the post office say you have to use the postmaster to get something from one box to another. You aren't allowed to stuff something into someone else's box on your own. Most older microprocessors work the same way. Almost everything you do with a micro has to go through the CPU's "hands." Some of the newest micros do have very powerful "memory-to-memory" transfer features built into their architectures, but this is not yet common. We see that the postmaster also has several sorting bins that sim- plify handling mail. Most pieces of mail have to go through one or more of these temporary stashes to allow sorting, routing, or for- warding. Some of the stashes are simple bins that can be used any old way the postmaster wants. Others have one special use, such as the safe for registered mail. The CPU in a microprocessor also has its sorting bins. These are called the |/to working registers|/tx of the micro. Working registers are involved in practically all micro actions. Some of these working reg- isters are very general stashes that can be used any way you like. Others have one special use. Some microprocessors have lots of working registers. Others may have fewer working registers but will have very fancy ways of getting things between the registers and the address space. These fancy ways are called |/to address modes|/tx , and we will see lots more on them shortly. Buzzwords\274) cf 11 4 15.2 lines (|p|y |4ADDRESS SPACE|j\261|j|5The "reach" of a microprocessor's CPU. The total number of available locations the CPU can communicate with. |4WORKING REGISTERS|j\261|j|5Temporary stashes available inside the micro's CPU that involve themselves with practically everything the CPU does. |4ADDRESS MODES|j\261|j|5Ways for the CPU to get something into or out of a working register of an address space location.) setoldgraybox (|310) showleftpagenumber showpage page2snap restore %%%%%%%%%%%%%%%%%%%%%%% save /page3snap exch store setupshow setuppage settextparams 0 44 lines (|p|y In most micros, the address space is |/to outside|/tx the microprocessor chip and the CPU while the working registers are |/to inside|/tx the micro- processor chip. This is similar to the user boxes, which are available to anyone from the lobby, compared to the sorting bins, which are available only to the postal employees. Some single-chip micros do include some or all of their address space internally, but in general, the address space area is separate and different from the working register area. Let's take a closer look at one of our post office boxes. We'll assume it's in a small western town where everybody goes to the post office to get their mail. A typical box looks like this\274) cf 0 5 lines (|p|y Repeating, an address is a location, and data is what goes in that location. Each address in a microcomputer must be unique. No mix- ups can be allowed. The addresses in the address space are often identified by a hex number. The working registers are usually iden- tified by name or by a single letter. ) cf 2.5 7 lines (|/autoimageandlink2 ) cl (|311) showrightpagenumber showpage page3snap restore %%%%%%%%%%%%%%%%%%%%%%% % EOF