TIP: Click on subject to list as thread! ANSI
echo: 80xxx
to: TOM TORFS
from: JAN WAGEMAKERS
date: 1997-11-28 15:35:00
subject: leal

Hi Tom,
Tom Torfs wrote to Jan Wagemakers :
 JW>> I have asked in Cprog.B a question about how it is possible with the
 JW>> C-programming-language to get the current time. I have get there a
 JW>> really useful answer and even have learned some things about C :-)
 TT> Thanks for the free advertising  (in case anyone wonders, I
 TT> moderate the above mentioned echo
Yes, and the "really useful answer" was also given by you :-)
 JW>> I don't understand what "leal -4(%ebp),%eax" exactly do.
 TT> Load effective address of ebp-4 into eax, in other words the
 TT> equivalent of mov eax,ebp followed by sub eax,4
 JW>> pushl %ebp movl %esp,%ebp
 TT> the above code sets up a stack frame
 JW>> subl $8,%esp
 TT> assigns 8 bytes on the stack for local variables
 JW>> leal -4(%ebp),%eax
 TT> load the address of a certain local variable (t) at ebp-4 in eax
 JW>> pushl %eax
 TT> and push it as a parameter to time()
 JW>> call time
Ok, Tom, I think that I understand this a little-bit. Now with the above in
mind, can you tell me what is wrong with the following piece of code that
gives a nice segmentation fault? :
/* (tijd.s)
        .globl main
main:
        movl $current_time,%eax
        pushl %eax
        call time
        addl $4,%esp
        ret
current_time:
        .word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.END
*/
/*
Free:~/assembler/time$ tijd
Unable to handle kernel paging request at virtual address 08048483
current->tss.cr3 = 00601000, %cr3 = 00601000
*pde = 00502067
*pte = 00634025
Oops: 0003
CPU:    0
EIP:    0010:[]
EFLAGS: 00010246
eax: c0ad5c0c   ebx: 08048483   ecx: 347ee8c2   edx: 00000000
esi: 40005d40   edi: 080483d0   ebp: bffffae4   esp: c064afbc
ds: 0018   es: 0018   ss: 0018
Process tijd (pid: 132, process nr: 22, stackpage=c064a000)
Stack: c0ad5c0c c010a3f6 08048483 0804955c 00000000 40005d40 080483d0 
ffffae4
       0000000d 0000002b 0000002b 0000000d 4005d612 00000023 00000286 
ffffae0
       0000002b
Call Trace: []
Code: 89 0b 85 d2 74 05 b9 f2 ff ff ff 89 c8 5b c3 90 53 8b 5c 24
Segmentation fault
*/
 TT> greetz, Tom
Regards                                - Jan Wagemakers - 
 
o_o COITUS INTERRUPTUS : a mission impossible                      (Fad 
Gadget) 
--- Terminate 5.00/Pro /Linux.DosEmu.JanW-DOS(PTS)
---------------
* Origin: Linux & Assembler : http://bewoner.dma.be/JanW (2:292/854.19)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.