{"id":232428,"date":"2025-06-12T00:48:37","date_gmt":"2025-06-12T00:48:37","guid":{"rendered":"https:\/\/learnexams.com\/blog\/?p=232428"},"modified":"2025-06-12T00:48:39","modified_gmt":"2025-06-12T00:48:39","slug":"program-org-8000-lxi-h-8091h-lxi-b-8061h-lda-b-8060h-result-store-mov-d-a-loop-ldax-b-cmp-m-jnz-skip-inx-h-inx-b-dcr-d-jnz-loop-mvi-a-00h-sta-8070h-hlt-skip-mvi-a-ff-sta-8070h-hlt","status":"publish","type":"post","link":"https:\/\/www.learnexams.com\/blog\/2025\/06\/12\/program-org-8000-lxi-h-8091h-lxi-b-8061h-lda-b-8060h-result-store-mov-d-a-loop-ldax-b-cmp-m-jnz-skip-inx-h-inx-b-dcr-d-jnz-loop-mvi-a-00h-sta-8070h-hlt-skip-mvi-a-ff-sta-8070h-hlt\/","title":{"rendered":"Program: ORG 8000 LXI H, 8091H LXI B, 8061H LDA B, 8060H \/\/ Result Store MOV D, A LOOP: LDAX B CMP M JNZ SKIP: INX H INX B DCR D JNZ LOOP MVI A, 00H STA, 8070H HLT SKIP: MVI A, FF STA, 8070H HLT"},"content":{"rendered":"\n<p>Program: ORG 8000 LXI H, 8091H LXI B, 8061H LDA B, 8060H \/\/ Result Store MOV D, A LOOP: LDAX B CMP M JNZ SKIP: INX H INX B DCR D JNZ LOOP MVI A, 00H STA, 8070H HLT SKIP: MVI A, FF STA, 8070H HLT<\/p>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">The Correct Answer and Explanation is:<\/mark><\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd27 <strong>Corrected Assembly Code for Clarity<\/strong>:<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">asmCopyEdit<code>LXI H, 8091H       ; HL points to data to be compared\nLXI B, 8061H       ; BC points to data list start\nLDA 8060H          ; A &lt;- Count (number of bytes to compare)\nMOV D, A           ; Store count in D (loop counter)\n\nLOOP: LDAX B       ; A &lt;- [BC] (load byte from data list)\nCMP M              ; Compare with value at HL\nJNZ SKIP           ; If not equal, jump to SKIP\nINX H              ; Increment HL to next value to compare\nINX B              ; Increment BC to next byte in list\nDCR D              ; Decrement count\nJNZ LOOP           ; If more bytes left, continue loop\n\nMVI A, 00H         ; If all matched, store 00H\nSTA 8070H\nHLT\n\nSKIP: MVI A, FFH   ; If mismatch, store FFH\nSTA 8070H\nHLT\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u2705 <strong>Correct Result Stored at <code>8070H<\/code><\/strong>:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If all <code>N<\/code> bytes in memory starting at <code>8061H<\/code> match <code>N<\/code> bytes starting at <code>8091H<\/code>, then <code>8070H = 00H<\/code>.<\/li>\n\n\n\n<li>If <strong>any mismatch occurs<\/strong>, then <code>8070H = FFH<\/code>.<\/li>\n<\/ul>\n\n\n\n<p>So, the program performs <strong>byte-by-byte comparison of two sequences<\/strong>, and:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Stores <code>00H<\/code> if <strong>all match<\/strong>.<\/li>\n\n\n\n<li>Stores <code>FFH<\/code> if <strong>any mismatch<\/strong>.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcd8 <strong>Textbook-Style Explanation (300 Words)<\/strong>:<\/h3>\n\n\n\n<p>This 8085 microprocessor program compares two blocks of memory and sets a flag value depending on whether they are identical. The number of bytes to be compared is first loaded from memory address <code>8060H<\/code> using the <code>LDA<\/code> instruction. This value is stored in register <code>D<\/code> to act as a loop counter.<\/p>\n\n\n\n<p>Two register pairs are initialized using <code>LXI<\/code> instructions: HL is set to point to the beginning of the first memory block (starting at <code>8091H<\/code>), and BC is set to point to the second memory block (starting at <code>8061H<\/code>).<\/p>\n\n\n\n<p>Inside the loop, the program fetches a byte from the memory location pointed to by BC using the <code>LDAX B<\/code> instruction and compares it to the byte pointed to by HL using the <code>CMP M<\/code> instruction. If the bytes do not match, control jumps to the label <code>SKIP<\/code>, where the accumulator is loaded with <code>FFH<\/code> to indicate mismatch, and this value is stored at memory location <code>8070H<\/code> using <code>STA<\/code>.<\/p>\n\n\n\n<p>If the bytes match, both HL and BC are incremented to point to the next bytes, and the counter <code>D<\/code> is decremented. If <code>D<\/code> is not zero, the loop repeats. If all comparisons are successful, the loop completes and the accumulator is loaded with <code>00H<\/code>, indicating a successful match. This value is stored in memory location <code>8070H<\/code>.<\/p>\n\n\n\n<p>Finally, the program halts using <code>HLT<\/code>. Thus, the memory location <code>8070H<\/code> acts as a result flag: <code>00H<\/code> if blocks match entirely, or <code>FFH<\/code> if any mismatch is found.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/learnexams.com\/blog\/wp-content\/uploads\/2025\/06\/learnexams-banner9-283.jpeg\" alt=\"\" class=\"wp-image-232429\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Program: ORG 8000 LXI H, 8091H LXI B, 8061H LDA B, 8060H \/\/ Result Store MOV D, A LOOP: LDAX B CMP M JNZ SKIP: INX H INX B DCR D JNZ LOOP MVI A, 00H STA, 8070H HLT SKIP: MVI A, FF STA, 8070H HLT The Correct Answer and Explanation is: \ud83d\udd27 Corrected Assembly [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25],"tags":[],"class_list":["post-232428","post","type-post","status-publish","format-standard","hentry","category-exams-certification"],"_links":{"self":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/posts\/232428","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/comments?post=232428"}],"version-history":[{"count":0,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/posts\/232428\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/media?parent=232428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/categories?post=232428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/tags?post=232428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}