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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:11:28+00:00 2026-05-13T12:11:28+00:00

In my project I need to use inline Assembly, but it need to be

  • 0

In my project I need to use inline Assembly, but it need to be Nasm, because I’m not too much familiar with GAS.
My try:

void DateAndTime()
{
   asm
   (.l1:    mov al,10           ;Get RTC register A
    out RTCaddress,al
    in al,RTCdata
    test al,0x80            ;Is update in progress?
    jne .l1             ; yes, wait

    mov al,0            ;Get seconds (00 to 59)
    out RTCaddress,al
    in al,RTCdata
    mov [RTCtimeSecond],al

    mov al,0x02         ;Get minutes (00 to 59)
    out RTCaddress,al
    in al,RTCdata
    mov [RTCtimeMinute],al

    mov al,0x04         ;Get hours (see notes)
    out RTCaddress,al
    in al,RTCdata
    mov [RTCtimeHour],al

    mov al,0x07         ;Get day of month (01 to 31)
    out RTCaddress,al
    in al,RTCdata
    mov [RTCtimeDay],al

    mov al,0x08         ;Get month (01 to 12)
    out RTCaddress,al
    in al,RTCdata
    mov [RTCtimeMonth],al

    mov al,0x09         ;Get year (00 to 99)
    out RTCaddress,al
    in al,RTCdata
    mov [RTCtimeYear],al

    ret);
}

There is any way to do this but using Nasm instead of GAS?

I think I need to add a argument when compiling.

  • 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-05-13T12:11:28+00:00Added an answer on May 13, 2026 at 12:11 pm

    I did a quick google on ‘nasm + gcc’, have a look here, here, and here.

    In a nutshell the switches to be used for nasm in order to link along with the gcc compiled object is:

    nasm -f elf
    

    Edit: The above was absolutely irrelevant as Nathan was looking for a GAS syntax similar to the code snippet in the question..here is my attempt of the GAS’ified version…

    void DateAndTime()
    {
       int RTCaddress, RTCdata, RTCtimeSecond, RTCtimeHour, RTCtimeMinute, RTCtimeDay, RTCtimeMonth, RTCtimeYear;
       // Set RTCaddress and RTCdata respectively first...
       RTCaddress = 0x70;
       RTCdata = 0x71; 
       asm
       (
    .l1:    
        movb $10, %al           ;Get RTC register A
        out %al, RTCaddress        ; Think RTCaddress needs to be declared...
        in RTCdata, %al            ; RTCdata needs to be declared
        test $80, %al            ;Is update in progress?
        jne .l1             ; yes, wait
    
        movb $0, %al            ;Get seconds (00 to 59)
        out %al, RTCaddress
        in RTCdata, %al
        movb %al, [RTCtimeSecond]
    
        movb $2, %al         ;Get minutes (00 to 59)
        out %al, RTCaddress
        in RTCdata, %al
        movb %al, [RTCtimeMinute]
    
        movb $4, %al         ;Get hours (see notes)
        out %al, RTCaddress
        in RTCdata, %al
        movb %al, [RTCtimeHour]
    
        movb $7, %al         ;Get day of month (01 to 31)
        out %al, RTCaddress
        in RTCdata, %al
        movb %al, [RTCtimeDay]
    
        movb $8, %al         ;Get month (01 to 12)
        out %al, RTCaddress
        in RTCdata, %al
        movb %al, [RTCtimeMonth]
    
        movb $9, %al         ;Get year (00 to 99)
        out %al, RTCaddress
        in RTCdata, %al
        movb %al, [RTCtimeYear]
    
        ret);
    

    Judging by the BIOS data where the RTC clock is, ports used is 0x70, 0x71 which I have used here… I may be wrong…

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

Sidebar

Related Questions

No related questions found

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.