Hello, I'm trying to print date and time in linux usign GAS (GNU assembler). I started from a hello world code and I modified to show system date and time.
I'm stuck in two very basic errors I can't seem to find solution. Here's the code:
When I compile withCode:############################################################################## ## getdatetime.s ## ## ## ## Compile with: ## ## as -o getdatetime.o getdatetime.s && ld -o getdatetime -O0 getdatetime.o ## ## ## ############################################################################## .section .data .section .text .globl _start _start: # call function to print date and time jmp print_date_time ## terminate program via _exit () system call xorl %eax, %eax # %eax = 0 incl %eax # %eax = 1 system call _exit () xorl %ebx, %ebx # %ebx = 0 normal program return code int $0x80 # execute system call _exit () ## get system date and time and push it in stack: sec/min/hour/day/mon/year print_date_time: movl $78, %eax # getdatetime () system call int $0x80 # execute system call getdatetime () addl $0x48, %eax # convert to ascii value mov %al, %ecx # print %al to see if we have something interesting in it (sec, min, hour, day, mon, year) or something movl $1, %edx # %edx = 1 = print length movl $4, %eax # write () system call int $0x80 # execute write () system call ret
It gives me an error:Code:as -o getdatetime.o getdatetime.s && ld -o getdatetime -O0 getdatetime.o
Line 27 is:Code:getdatetime.s: Assembler messages: getdatetime.s:27: Error: suffix or operands invalid for `mov'
Thanks for your attention.Code:mov %al, %ecx # print %al to see if we have something interesting in it (sec, min, hour, day, mon, year) or something




Reply With Quote