Note that there are some explanatory texts on larger screens.

plurals
  1. POHandling of Hexadecimal numbers for 8051 Assembly
    primarykey
    data
    text
    <p>I am having trouble looping through the Hexadecimal numbers in 8051 Assembly for proper subtraction,</p> <p>Here is the simple code that iterate 30 times and shows value from 40 to 70 (40,41,42,43,....70)</p> <pre><code> MOV A,#40H ;first value of the loop MOV R0,#0H MOV R1,#30 ;Number of iterations LOOP: ADD A,R0 DA A ;To Adjust the decimal values after each addition INC A DJNZ R1,LOOP END </code></pre> <p>This is how it is adjusting each value,</p> <pre><code>; 40H = 64D --(+0D)--&gt; 64D = 40H ; 41H = 65D --(+0D)--&gt; 65D = 41H ; 42H = 66D --(+0D)--&gt; 66D = 42H ; 43H = 67D --(+0D)--&gt; 67D = 43H ; 44H = 68D --(+0D)--&gt; 68D = 44H ; 45H = 69D --(+0D)--&gt; 69D = 45H ; 46H = 70D --(+0D)--&gt; 70D = 46H ; 47H = 71D --(+0D)--&gt; 71D = 47H ; 48H = 72D --(+0D)--&gt; 72D = 48H ; 49H = 73D --(+0D)--&gt; 73D = 49H ; 4AH = 74D --(+6D)--&gt; 80D = 50H </code></pre> <p>But when i want to reverse the loop i.e if i want the output in reverse order from 70 to 40 (70,69,68,67,66,65,64,.....40)</p> <p>what should i have to do ?</p> <p>Here is the example how it should work if the first number is 90</p> <pre><code>; 90H = 144D --(+0D)--&gt; 144D = 90H ; 8FH = 143D --(-6D)--&gt; 137D = 89H ; 8EH = 142D --(-6D)--&gt; 136D = 88H ; 8DH = 141D --(-6D)--&gt; 135D = 87H ; 8CH = 140D --(-6D)--&gt; 134D = 86H ; 8BH = 139D --(-6D)--&gt; 133D = 85H ; 8AH = 138D --(-6D)--&gt; 132D = 84H </code></pre> <p>but since there is nothing for Decimal Adjust after subtraction how could i achieve the desired result ?</p> <p>The desired output,</p> <p>90 89 88 87 86 85....</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload