{"id":314,"date":"2011-12-26T19:04:59","date_gmt":"2011-12-27T01:04:59","guid":{"rendered":"http:\/\/tommysprinkle.com\/txxos\/?p=314"},"modified":"2021-04-17T18:23:59","modified_gmt":"2021-04-17T23:23:59","slug":"txxnuc00","status":"publish","type":"post","link":"https:\/\/tommysprinkle.com\/txxos\/?p=314","title":{"rendered":"TXXNUC00 &#8211; Beginning Of An OS"},"content":{"rendered":"<p>Our first version of a nucleus will not do much &#8211; but it will do something! \u00a0It will set a value in the Interval Timer. \u00a0The CPU will subtract from this value several times every second. \u00a0When the value goes to zero an External Interrupt will be generated. \u00a0This will cause the CPU to save the current PSW into the External Old PSW area in low core and load a new PSW from the External New PSW location. \u00a0In our interrupt routine we will reset the Interval Timer and load a PSW with the wait bit set &#8211; but enabled for interrupts.<\/p>\n<pre>TXXNUC   CSECT ,\r\n         DC    X'00',X'00',AL2(0),AL4(DISPINIT)  INITIAL PSW\r\n         DC    D'0'                              RST NEW PSW\r\n*\r\n         DC    A(CVT)                            COMM VECT TABLE\r\n         DC    A(MVT)                            MOD  VECT TABLE\r\n*\r\n         DC    D'0'          EXT OLD PSW\r\n         DC    D'0'          SVC OLD PSW\r\n         DC    D'0'          PGM OLD PSW\r\n         DC    D'0'          MCK OLD PSW\r\n         DC    D'0'          I\/O OLD PSW\r\n*\r\n         DC    D'0'          CHANNEL STATUS WORD\r\n         DC    F'0'          CHANNEL ADDRESS WORD\r\n         DC    F'0'\r\n         DC    F'0'          INTERVAL TIMER\r\n         DC    F'0'\r\n*\r\n         DC    X'00',X'00',AL2(0),AL4(EXTHNDLR)  EXT NEW PSW\r\n         DC    X'00',X'00',AL2(0),AL4(SVCHNDLR)  SVC NEW PSW\r\n         DC    X'00',X'00',AL2(0),AL4(PGMHNDLR)  PGM NEW PSW\r\n         DC    X'00',X'00',AL2(0),AL4(@E@MCK)    MCK NEW PSW\r\n         DC    X'00',X'00',AL2(0),AL4(IOHNDLR)   I\/O NEW PSW\r\n*\r\n*\r\nLOWCLEN  EQU   *-TXXNUC\r\nLOWCFILL EQU   1024-LOWCLEN\r\n         DC    (LOWCFILL)X'00'<\/pre>\n<p>We begin by filling in some low core values needed by the CPU. \u00a0We specify the PSW&#8217;s to be loaded when the corresponding interrupt occurs. \u00a0Finally we pad low core up to 1k (1024) with binary zeros.<\/p>\n<pre>EXTREGS  DC    16F'0'             EXT INTERRUPT REG SAVE\r\nIOREGS   DC    16F'0'             I\/O INTERRUPT REG SAVE\r\nSVCREGS  DC    16F'0'             SVC INTERRUPT REG SAVE\r\nPGMREGS  DC    16F'0'             PGM INTERRUPT REG SAVE\r\n*\r\n*\r\nCVT      DC    A(0)     +++ PLACE HOLDER +++\r\nMVT      DC    A(0)     +++ PLACE HOLDER +++<\/pre>\n<p>Next we go ahead and define some data areas. \u00a0These will not be used right now but they will be needed in later versions of our nucleus code.<\/p>\n<pre>         USING TXXNUC,0\r\n*\r\nSVCHNDLR DS    0H\r\nPGMHNDLR DS    0H\r\nIOHNDLR  DS    0H\r\n         LPSW  WAITPSW\r\n*\r\n         DS    0D\r\nWAITPSW  DC    X'00',X'02',AL2(0),A(X'EE9999')<\/pre>\n<p>If an SVC, Program, or I\/O interrupt occurs we load a disabled wait PSW.<\/p>\n<pre>EXTHNDLR DS    0H\r\n         L     R1,=A(X'80')       INTERVAL TIMER VALUE\r\n         ST    R1,ITIMER-@LOWCORE SAVE INTO TIMER\r\n*\r\n         LPSW  IWAIT              LOAD WAIT PSW\r\n*\r\n         DS    0D\r\nIWAIT    DC    AL1(255,2,0,0),AL4(X'FEAD')\r\n*\r\n*\r\nDISPINIT DS    0H\r\n         B     EXTHNDLR<\/pre>\n<p>When an External interrupt occurs we store a new value into the interval timer and then load an Enabled Wait PSW. \u00a0The PSW must be enabled for External interrupts so our interrupt routine will be invoked when the timer expires.<\/p>\n<pre>         @LOWCORE ,\r\n*\r\n         @REGS ,\r\n         @@ERR ,\r\n         END   ,<\/pre>\n<p>Finally we include our macros for mapping low core and registers. \u00a0I have also created a new macro called @@ERR to contain wait state codes.<\/p>\n<p>Once the nucleus is assembled and link edited as TXXNUC we can fire up Hercules and IPL from our DASD volume. \u00a0We should see our enabled wait PSW with the code &#8216;FEAD&#8217; and we should observe the CPU waking up and performing a few instructions before going \u00a0back into the wait state.<\/p>\n<p>[Next &#8211; <a title=\"Dispatcher\" href=\"http:\/\/tommysprinkle.com\/txxos\/?p=316\">Dispatcher<\/a>]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Our first version of a nucleus will not do much &#8211; but it will do something! \u00a0It will set a value in the Interval Timer. \u00a0The CPU will subtract from this value several times every second. \u00a0When the value goes &hellip; <a href=\"https:\/\/tommysprinkle.com\/txxos\/?p=314\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"template-page-builder-no-sidebar.php","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-314","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/s1CPQT-txxnuc00","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=\/wp\/v2\/posts\/314","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=314"}],"version-history":[{"count":5,"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=\/wp\/v2\/posts\/314\/revisions"}],"predecessor-version":[{"id":327,"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=\/wp\/v2\/posts\/314\/revisions\/327"}],"wp:attachment":[{"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}