Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8766993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:41:34+00:00 2026-06-13T16:41:34+00:00

I am having trouble looping through the Hexadecimal numbers in 8051 Assembly for proper

  • 0

I am having trouble looping through the Hexadecimal numbers in 8051 Assembly for proper subtraction,

Here is the simple code that iterate 30 times and shows value from 40 to 70 (40,41,42,43,….70)

        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

This is how it is adjusting each value,

; 40H = 64D --(+0D)--> 64D = 40H
; 41H = 65D --(+0D)--> 65D = 41H
; 42H = 66D --(+0D)--> 66D = 42H
; 43H = 67D --(+0D)--> 67D = 43H
; 44H = 68D --(+0D)--> 68D = 44H
; 45H = 69D --(+0D)--> 69D = 45H
; 46H = 70D --(+0D)--> 70D = 46H
; 47H = 71D --(+0D)--> 71D = 47H
; 48H = 72D --(+0D)--> 72D = 48H
; 49H = 73D --(+0D)--> 73D = 49H 
; 4AH = 74D --(+6D)--> 80D = 50H

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)

what should i have to do ?

Here is the example how it should work if the first number is 90

; 90H = 144D --(+0D)--> 144D = 90H
; 8FH = 143D --(-6D)--> 137D = 89H
; 8EH = 142D --(-6D)--> 136D = 88H
; 8DH = 141D --(-6D)--> 135D = 87H
; 8CH = 140D --(-6D)--> 134D = 86H
; 8BH = 139D --(-6D)--> 133D = 85H
; 8AH = 138D --(-6D)--> 132D = 84H

but since there is nothing for Decimal Adjust after subtraction how could i achieve the desired result ?

The desired output,

90
89
88
87
86
85….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:41:36+00:00Added an answer on June 13, 2026 at 4:41 pm

    You can’t subtract 1, but you can add 99.

    ADD A, #99H
    DA A
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having some trouble looping through these arrays , i have 4 properties that identical
I'm having trouble looping through a set of dynamically created UITextFields and storing those
I'm having some trouble with looping and creating MS Excel docs, code snippet below
Im having some trouble looping through some xml data. The xml file is structured
I'm trying to create an array of hashes, but I'm having trouble looping through
Having trouble looping through multiple rows in a SQL table and getting the info
Hey guys I'm having trouble looping through some XML. Im trying to capture the
I am having some trouble with my program logic that loops through a collection
OK, I'm having trouble looping through these sub-nodes. For this example, I'll show you
Having trouble with each function... Will try to explain by example... In my code,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.