flat assembler
Message board for the users of flat assembler.
Index
> Linux > Bios interrupts not allowed? |
Author |
|
LocoDelAssembly 31 Mar 2009, 20:12
Quote:
I think you cannot. From lscr help ( http://lscr.sourceforge.net/ ) I have extracted this: Code: sys_time [kernel/time.c] Returns the time since the Epoch (00:00:00 UTC, January 1, 1970), measured in seconds. Arguments eax 13 ebx Pointer to an integer which will receive the return value. If ebx is 0, then time is returned only in eax. Return values If the system call succeeds the return value is the time in seconds since the Epoch. If the system call fails the return value is one of the following errno values: -EFAULT ebx points outside your accessible address space. Remarks n/a Compatibility n/a So I suppose that in this way you can get the number of seconds since Epoch: Code: mov eax, 13 xor ebx, ebx int 80h |
|||
31 Mar 2009, 20:12 |
|
buzzkill 31 Mar 2009, 20:59
Andy,
Since Linux (like all modern OSes) runs in protected mode, you can't use any BIOS/real mode interrupts natively. There are some libraries that let you emulate a real mode interface, like eg these two: - lrmi : "library for calling real mode BIOS routines under Linux", http://www.sourceforge.net/projects/lrmi/ - libx86 : "A hardware-independent library for executing real-mode x86 code", http://www.codon.org.uk/~mjg59/libx86 but I've never used these myself, so I can't tell you how well these work. If you just want the time from the linux kernel, use a syscall like LocoDelAssembly said. If you want to learn assembly by starting with real mode programming, I think you'd be better of emulating a complete real-mode environment and work in that. Eg dosbox and dosemu can provide you with a DOS environment (DOS is a real-mode OS), and you can run your code in there. There's also bochs, which emulates a complete PC (with integrated debugger), so you can even develop your own real mode OS in it if you like. I have used these three solutions for various things and they all work great. |
|||
31 Mar 2009, 20:59 |
|
LocoDelAssembly 31 Mar 2009, 21:16
Quote:
This one can't run under AMD64 kernels, right? Also root user is required? Great lib anyway, it is also small enough to port it to Assembly or just grab the essential parts. |
|||
31 Mar 2009, 21:16 |
|
Endre 01 Apr 2009, 09:30
I think you should use syscall 78 and then libc's localtime function (this latter is not necessary of course, you can implement it by yourself ).
|
|||
01 Apr 2009, 09:30 |
|
buzzkill 01 Apr 2009, 14:57
Quote: This one can't run under AMD64 kernels, right? Also root user is required? If you're asking me, I don't know. Like I said, I've never used this library myself Quote: I think you should use syscall 78 and then libc's localtime function Normally, you would choose one of the two: either syscall when you want to do the work yourself, or the libc wrapper if you want to make it easier for yourself (and don't mind linking to libc). |
|||
01 Apr 2009, 14:57 |
|
andyz74 01 Apr 2009, 16:11
Thank U all for your help!
LocoDelAssembly, I think I'll try the "eax=13 / int 80h" solution, this seems to be the easiest. Due to lack of intelligence, I'm always forced to take easy solutions. Again thank U all! |
|||
01 Apr 2009, 16:11 |
|
Endre 02 Apr 2009, 13:48
Quote: Normally, you would choose one of the two: either syscall when you want to do the work yourself, or the libc wrapper if you want to make it easier for yourself (and don't mind linking to libc). |
|||
02 Apr 2009, 13:48 |
|
buzzkill 02 Apr 2009, 15:23
Quote: You might not know but int 78 and localtime don't substitute but complement each other. Colossal difference. And in what book did you read that mixing syscalls and libc-calls is to be avoided? Throw it away, it misleads you. What's wrong with using gettimeofday() ? What would be the advantage of using one syscall and one libc-call over either two syscalls or two libc calls? I never said that mixing the two should be avoided, I'm saying there's usually no point in mixing them: if you're already linked to libc to call localtime(), then why not call libc's gettimeofday() as well? |
|||
02 Apr 2009, 15:23 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.