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.
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:
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…
Judging by the BIOS data where the RTC clock is, ports used is 0x70, 0x71 which I have used here… I may be wrong…