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 8630415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:03:33+00:00 2026-06-12T09:03:33+00:00

I am having delay routines for 8051 micro-controller in assembly language.Ana I can use

  • 0

I am having delay routines for 8051 micro-controller in assembly language.Ana I can use them in assembly language programs but I want to use these routines from c language as these are generate perfect delay for me.

The code for delay that is delay.asm file I post just beleow…

;ALL DELAYS ROUTINES HERE
DELAY_SEG SEGMENT CODE
RSEG DELAY_SEG
;DELAY OF 1MS SUBROUTINE
DELAY1MS:
     MOV R7,#250
     DJNZ R7,$
     MOV R7,#247
     DJNZ R7,$
     RET
;DELAY OF 100MS SUBROUTINE
DELAY100MS:
     MOV R6,#99;1MUS
L1:
     ACALL DELAY1MS ;99MS
     DJNZ R6,L1;198MUS
     MOV R6,#250;1MUS
     DJNZ R6,$;500US
     MOV R6,#147;1US
     DJNZ R6,$;294US
     NOP
     RET;1US
;DELAY 0F 1SEC SUB ROUTINE
DELAY1S:
     MOV R5,#9
L2:
     ACALL DELAY100MS
     DJNZ R5,L2
     MOV R5,#99
L3:
     ACALL DELAY1MS
     DJNZ R5,L3
     MOV R5,#250
     DJNZ R5,$
     MOV R5,#138
     DJNZ R5,$
     RET

I include this code in assembly language and use simply.But I want to call these routines from c source code.

  • 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-12T09:03:34+00:00Added an answer on June 12, 2026 at 9:03 am

    To properly interface your assembler functions you need to do the following steps:

    • give your module the same NAME as it’s file name without extension (I
      assume that your source file has name delays.a51):
    MODULE DELAYS
    
    • prepend each function name that you want to be visible in C modules with underscore.

    • for each function you need to declare a separate code segment with
      the following naming convention:

    ?PR?FunctionName?ModuleName

    • put each function into it’s own segment.
    • also each function name should be made PUBLIC

    Thus, for your DELAY1MS function you have the following:

    ?PR?_DELAY1MS?DELAYS    SEGMENT CODE
        RSEG        ?PR?_DELAY1MS?DELAYS
        PUBLIC      _DELAY1MS
    _DELAY1MS:
        ...
        ...
        RET
    

    To make functions available to the C compiler you should declare them without any mangling (no underscore), so for DELAY1MS you have:

    void Delay1ms(void);

    All this tricky games with names & segments are required for the linker as it builds the graph of calls to allocate memory statically for local variables at link time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the easiest/simplest way to delay inside a function without having to delay
I'm having trouble getting some javascript and Jquery to delay the appropriate amount of
Having used storyboards for a while now I have found them extremely useful however,
Having trouble with an .htaccess file on WAMP. Works on the live server, but
I'm having some trouble understanding how the delay macro works in Clojure. It doesn't
After much delay, I realize I want to implement a version control system into
Having a problem I can't seem to put my finger on. I am trying
I am having trouble understanding this java code. I want the image to twinkle
I'm having trouble getting my CSS 3 button to operate properly. You can view
I'm simply trying to delay an action before it starts but I seem to

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.