{"id":150,"date":"2011-11-18T13:52:51","date_gmt":"2011-11-18T19:52:51","guid":{"rendered":"http:\/\/tommysprinkle.com\/txxos\/?p=150"},"modified":"2021-04-17T18:28:37","modified_gmt":"2021-04-17T23:28:37","slug":"macro-rgck","status":"publish","type":"post","link":"https:\/\/tommysprinkle.com\/txxos\/?p=150","title":{"rendered":"Macro &#8211; @RGCK"},"content":{"rendered":"<p>Our next macro is a utility macro to help us load data into a register.<\/p>\n<p>The macro will examine the operand and determine what action to take.\u00a0 There are four possible actions depending on the operand.<\/p>\n<p>(Rx) &#8211; will generate a LR to load the target register from the operand register Rx<\/p>\n<p>(addr) &#8211; Will generate a L to load the target register with the data at address location addr.<\/p>\n<p>addr &#8211; Will generage a LA to load the target register with the value addr<\/p>\n<p>&#8216;string&#8217; &#8211; Will generate a LA to load the target register with a literal string.\u00a0 The default string type is C for character.\u00a0 Optionally a length may be specified.<\/p>\n<pre>         MACRO\r\n&amp;NAME    @RGCK &amp;FLD,&amp;REG=,&amp;LEN=,&amp;TYPE=C<\/pre>\n<p>The macro has four parameters, two of which must be specified.\u00a0 &amp;FLD is the operand.\u00a0 &amp;REG is the target register and should be specified in using an Equated value (Rx).\u00a0 &amp;LEN\u00a0 is optional and is used to specify a length when a literal string is generated.\u00a0 If &amp;LEN is not specified, no explicit length will be used for the literal.\u00a0 &amp;TYPE indicates the type of literal to be generated.\u00a0 If &amp;TYPE is not specified, C will be assumed for character.<\/p>\n<pre>         AIF   ('&amp;FLD'(1,1) NE '(').NOREG\r\n         AIF   ('&amp;FLD(1)'  EQ '&amp;REG').DONE\r\n.*\r\n         AIF   ('&amp;FLD(1)' EQ 'R0').LR\r\n         AIF   ('&amp;FLD(1)' EQ 'R1').LR<\/pre>\n<p>First we check to see if the operand is enclosed in parentheses indicating either a register or a target for a LA.\u00a0 We do this by checking the first character of the &amp;FLD parameter.\u00a0 If the target and operand registers are both the same then there is nothing to be done and we can exit.\u00a0 Else the operand is checked against the our standard register equate names (Rx).\u00a0 If it matches a value from R0 &#8211; R16 we branch to the .LR label.<\/p>\n<pre>         AIF   ('&amp;FLD(1)' EQ 'R15').LR\r\n.*\r\n&amp;NAME    L     &amp;REG,&amp;FLD(1)\r\n         MEXIT ,<\/pre>\n<p>If no match is found we fall through the tests and generate a L instruction.<\/p>\n<pre>.NOREG   ANOP  ,\r\n         AIF   ('&amp;FLD'(1,1) EQ '''').STRING\r\n&amp;NAME    LA    &amp;REG,&amp;FLD(1)\r\n         MEXIT ,\r\n.*\r\n.*<\/pre>\n<p>Now we check for a string indicated by a single quote in the first position of the operand.\u00a0 If it is not a string we generate a LA.<\/p>\n<pre>.STRING  ANOP  ,\r\n         AIF   (T'&amp;LEN EQ 'O').NOLEN\r\n&amp;NAME    LA    &amp;REG,=&amp;TYPE.L&amp;LEN&amp;FLD\r\n         MEXIT ,\r\n.NOLEN   ANOP  ,\r\n&amp;NAME    LA    &amp;REG,=&amp;TYPE&amp;FLD\r\n          MEND<\/pre>\n<p>If it is a string we check to see if a length value (&amp;LEN) is specified.\u00a0 If not we generate a LA for a literal with no length specification.\u00a0 Else we generate the LA using the specified length value for our literal.<\/p>\n<p>Below is the full macro.<\/p>\n<hr \/>\n<pre>         MACRO\r\n&amp;NAME    @RGCK &amp;FLD,&amp;REG=,&amp;LEN=,&amp;TYPE=C\r\n.*\r\n         AIF   ('&amp;FLD'(1,1) NE '(').NOREG\r\n         AIF   ('&amp;FLD(1)'  EQ '&amp;REG').DONE\r\n.*\r\n         AIF   ('&amp;FLD(1)' EQ 'R0').LR\r\n         AIF   ('&amp;FLD(1)' EQ 'R1').LR\r\n         AIF   ('&amp;FLD(1)' EQ 'R2').LR\r\n         AIF   ('&amp;FLD(1)' EQ 'R3').LR\r\n         AIF   ('&amp;FLD(1)' EQ 'R4').LR\r\n         AIF   ('&amp;FLD(1)' EQ 'R5').LR\r\n         AIF   ('&amp;FLD(1)' EQ 'R6').LR\r\n         AIF   ('&amp;FLD(1)' EQ 'R7').LR\r\n         AIF   ('&amp;FLD(1)' EQ 'R8').LR\r\n         AIF   ('&amp;FLD(1)' EQ 'R9').LR\r\n         AIF   ('&amp;FLD(1)' EQ 'R10').LR\r\n         AIF   ('&amp;FLD(1)' EQ 'R11').LR\r\n         AIF   ('&amp;FLD(1)' EQ 'R12').LR\r\n         AIF   ('&amp;FLD(1)' EQ 'R13').LR\r\n         AIF   ('&amp;FLD(1)' EQ 'R14').LR\r\n         AIF   ('&amp;FLD(1)' EQ 'R15').LR\r\n.*\r\n&amp;NAME    L     &amp;REG,&amp;FLD(1)\r\n         MEXIT ,\r\n.*\r\n.*\r\n.LR      ANOP  ,\r\n&amp;NAME    LR    &amp;REG,&amp;FLD(1)\r\n.DONE    ANOP  ,\r\n         MEXIT ,\r\n.*\r\n.*\r\n.NOREG   ANOP  ,\r\n         AIF   ('&amp;FLD'(1,1) EQ '''').STRING\r\n&amp;NAME    LA    &amp;REG,&amp;FLD(1)\r\n         MEXIT ,\r\n.*\r\n.*\r\n.STRING  ANOP  ,\r\n         AIF   (T'&amp;LEN EQ 'O').NOLEN\r\n&amp;NAME    LA    &amp;REG,=&amp;TYPE.L&amp;LEN&amp;FLD\r\n         MEXIT ,\r\n.NOLEN   ANOP  ,\r\n&amp;NAME    LA    &amp;REG,=&amp;TYPE&amp;FLD\r\n          MEND<\/pre>\n<hr \/>\n<p><a title=\"Macro \u2013 @PRINT\" href=\"http:\/\/tommysprinkle.com\/txxos\/?p=153\">[Next &#8211; Macro @PRINT]<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Our next macro is a utility macro to help us load data into a register. The macro will examine the operand and determine what action to take.\u00a0 There are four possible actions depending on the operand. (Rx) &#8211; will generate &hellip; <a href=\"https:\/\/tommysprinkle.com\/txxos\/?p=150\">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-150","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1CPQT-2q","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=\/wp\/v2\/posts\/150","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=150"}],"version-history":[{"count":4,"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=\/wp\/v2\/posts\/150\/revisions"}],"predecessor-version":[{"id":211,"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=\/wp\/v2\/posts\/150\/revisions\/211"}],"wp:attachment":[{"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}