{"id":392,"date":"2016-12-31T15:11:02","date_gmt":"2016-12-31T15:11:02","guid":{"rendered":"http:\/\/teachcomputerscience.com\/?p=392"},"modified":"2024-07-24T12:38:40","modified_gmt":"2024-07-24T12:38:40","slug":"lda-and-sta-instructions-load-save","status":"publish","type":"post","link":"https:\/\/teachcomputerscience.com\/lda-and-sta-instructions-load-save\/","title":{"rendered":"LDA and STA Instructions &#8211; LMC Load and Save"},"content":{"rendered":"<div class=\"gb-container gb-container-a1102261 upsell-block\"><div class=\"gb-inside-container\">\n<div class=\"gb-grid-wrapper gb-grid-wrapper-ecba04d3\">\n<div class=\"gb-grid-column gb-grid-column-f3b10026\"><div class=\"gb-container gb-container-f3b10026\"><div class=\"gb-inside-container\">\n\n<h2 class=\"gb-headline gb-headline-8c059ea2 gb-headline-text\">KS3 Programming Constructs (14-16 years)<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>An editable PowerPoint lesson presentation<\/li><li>Editable revision handouts<\/li><li>A glossary which covers the key terminologies of the module<\/li><li>Topic mindmaps for visualising the key concepts<\/li><li>Printable flashcards to help students engage active recall and confidence-based repetition<\/li><li>A quiz with accompanying answer key to test knowledge and understanding of the module<\/li><\/ul>\n\n\n<div class=\"gb-button-wrapper gb-button-wrapper-3eedd793\">\n\n<a class=\"gb-button gb-button-8f067130 gb-button-text\" href=\"https:\/\/teachcomputerscience.com\/ks3\/programming\/programming-constructs\/\">View KS3 Programming Constructs<\/a>\n\n<\/div>\n<\/div><\/div><\/div>\n\n<div class=\"gb-grid-column gb-grid-column-d0f0ac83\"><div class=\"gb-container gb-container-d0f0ac83\"><div class=\"gb-inside-container\">\n\n<h2 class=\"gb-headline gb-headline-67dbf7aa gb-headline-text\">A-Level Functions and procedures (16-18 years)<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>An editable PowerPoint lesson presentation<\/li><li>Editable revision handouts<\/li><li>A glossary which covers the key terminologies of the module<\/li><li>Topic mindmaps for visualising the key concepts<\/li><li>Printable flashcards to help students engage active recall and confidence-based repetition<\/li><li>A quiz with accompanying answer key to test knowledge and understanding of the module<\/li><\/ul>\n\n\n<div class=\"gb-button-wrapper gb-button-wrapper-3d8f524b\">\n\n<a class=\"gb-button gb-button-f8128b9e gb-button-text\" href=\"https:\/\/teachcomputerscience.com\/a-level\/problem-solving-and-programming\/functions-and-procedures\/\">View A-Level Functions and procedures Resources<\/a>\n\n<\/div>\n<\/div><\/div><\/div>\n<\/div>\n<\/div><\/div>\n\n\n\n<p>The following program will demonstrate the use of LDA and STA, the Load and Save instructions used in the LMC.<\/p>\n<p>Running the program: when prompted, INPUT a set of two numbers. The program should then OUTPUT them in the same order that they were entered.<\/p>\n<table class=\"rcp-table\">\n<tbody>\n<tr>\n<td>INP<br \/><strong>STA<\/strong> <span class=\"style6\">first<\/span><br \/>INP<br \/><strong>STA<\/strong> <span class=\"style9\">second<\/span><br \/><strong>LDA<\/strong> <span class=\"style6\">first<\/span><br \/>OUT<br \/><strong>LDA<\/strong> <span class=\"style9\">second<\/span><br \/>OUT<br \/>HLT<br \/><span class=\"style6\">first<\/span> DAT<br \/><span class=\"style9\">second<\/span> DAT<\/td>\n<td>0 INP<br \/>1 <strong>STA<\/strong> <span class=\"style6\">9<\/span><br \/>2 INP<br \/>3 <strong>STA<\/strong> <span class=\"style9\">10<\/span><br \/>4 <strong>LDA<\/strong> <span class=\"style6\">9<\/span><br \/>5 OUT<br \/>6 <strong>LDA<\/strong> <span class=\"style9\">10<\/span><br \/>7 OUT<br \/>8 HLT<br \/><span class=\"style6\">9<\/span> DAT 0<br \/><span class=\"style9\">10<\/span> DAT 0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Instructions<\/h4>\n<ul>\n<li>Copy the eleven line program above and paste it into the Program box.<\/li>\n<li>Click on the &#8220;Assemble Program&#8221; button.<\/li>\n<li><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-393\" src=\"http:\/\/teachcomputerscience.com\/wp-content\/uploads\/2016\/12\/img6E.gif\" alt=\"Image\" width=\"372\" height=\"47\" title=\"\">After the program is assembled you should see RAM addresses 0 to 8 contain the machine code instructions shown in the image.<\/li>\n<li>Click on the RUN button.<\/li>\n<li>If you have difficulty following what is happening, read the explanation below and use STEP instead of RUN so you can follow each step.<\/li>\n<\/ul>\n<h4>Explanation<\/h4>\n<p><strong>first<\/strong> and <strong>second<\/strong> are used to label a <strong>DAT<\/strong> instruction. DAT identifies the 10th and 11th instructions as data. The labels therefore refer to RAM addresses 9 and 10 respectively (0-indexed counting).<\/p>\n<pre>0 INP \/\/the first input value is copied into the accumulator.\n 1 STA first \/\/the accumulator contents are stored in RAM address 9 (labelled\n first).\n 2 INP \/\/the second input value is copied into the accumulator.\n 3 STA second \/\/the accumulator contents are stored in RAM address 10 (labelled\n second).\n 4 LDA first \/\/the contents of memory address 9 (labelled first) are loaded into\n the accumulator.\n 5 OUT \/\/the value in the accumulator is sent to the OUTPUT.\n 6 LDA second \/\/the contents of memory address 10 (labelled second) are loaded into\n the accumulator.\n 7 OUT \/\/the value in the accumulator is sent to the OUTPUT.\n 8 HLT \/\/the program halts.<\/pre>\n<h4>Example results<\/h4>\n<p>INPUT= 2, 3<br \/>OUTPUT = 2, 3<\/p>\n\n\n<h3 class=\"gb-headline gb-headline-9cfffa28 gb-headline-text\">Further Readings:<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Little_man_computer\" target=\"_blank\" rel=\"noopener\">Little man computer<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The following program will demonstrate the use of LDA and STA, the Load and Save instructions used in the LMC. Running the program: when prompted, INPUT a set of two numbers. The program should then OUTPUT them in the same order that they were entered. INPSTA firstINPSTA secondLDA firstOUTLDA secondOUTHLTfirst DATsecond DAT 0 INP1 STA &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"LDA and STA Instructions &#8211; LMC Load and Save\" class=\"read-more button\" href=\"https:\/\/teachcomputerscience.com\/lda-and-sta-instructions-load-save\/\" aria-label=\"More on LDA and STA Instructions &#8211; LMC Load and Save\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_generate-full-width-content":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[16],"tags":[204,47],"class_list":["post-392","post","type-post","status-publish","format-standard","hentry","category-lmc","tag-article","tag-hide-old-upsell","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"acf":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/posts\/392","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/comments?post=392"}],"version-history":[{"count":2,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/posts\/392\/revisions"}],"predecessor-version":[{"id":607181,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/posts\/392\/revisions\/607181"}],"wp:attachment":[{"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/media?parent=392"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/categories?post=392"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/tags?post=392"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}