User talk:Ebarrier

From ICO wiki
Revision as of 00:36, 13 January 2016 by Ebarrier (talk | contribs)
Jump to navigationJump to search

etienne@etienne-ThinkPad-W520: ~/Documents lsb_release -a

   No LSB modules are available.
   Distributor ID:	Ubuntu
   Description:	Ubuntu 14.04.3 LTS
   Release:	14.04
   Codename:	trusty


etienne@etienne-ThinkPad-W520: ~/Documents uname -sr

   Linux 3.19.0-25-generic

etienne@etienne-ThinkPad-W520: ~/Documents cat /proc/cpuinfo

   processor	: 0
   vendor_id	: GenuineIntel
   cpu family	: 6
   model	: 42
   model name	: Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz
   stepping	: 7
   microcode	: 0x23
   cpu MHz	: 800.781
   cache size	: 8192 KB
   physical id	: 0
   siblings	: 8
   core id	: 0
   cpu cores	: 4
   apicid	: 0
   initial apicid	: 0
   fpu		: yes
   fpu_exception	: yes
   cpuid level	: 13
   wp		: yes
   bugs	:
   bogomips	: 4983.75
   clflush size	: 64
   cache_alignment	: 64
   address sizes	: 36 bits physical, 48 bits virtual
   power management:
   processor	: 1
   vendor_id	: GenuineIntel
   cpu family	: 6
   model	: 42
   model name	: Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz
   stepping	 : 7
   microcode	: 0x23
   cpu MHz	: 849.316
   cache size	 : 8192 KB
   physical id	 : 0
   siblings	: 8
   core id	: 0
   cpu cores	: 4
   apicid	: 1
   initial apicid	: 1
   fpu		: yes
   fpu_exception	: yes
   cpuid level : 13
   wp		: yes
   bugs	:
   bogomips	: 4983.75
   clflush size: 64
   cache_alignment	: 64
   address sizes	: 36 bits physical, 48 bits virtual
   power management:
   processor	: 2
   vendor_id	: GenuineIntel
   cpu family	: 6
   model	: 42
   model name	: Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz
   stepping	: 7
   microcode	: 0x23
   cpu MHz	: 801.074
   cache size	: 8192 KB
   physical id	: 0
   siblings	: 8
   core id	: 1
   cpu cores	: 4
   apicid	: 2
   initial apicid	: 2
   fpu		: yes
   fpu_exception	: yes
   cpuid level	: 13
   wp		: yes
   bugs		:
   bogomips	: 4983.75
   clflush size	: 64
   cache_alignment	: 64
   address sizes	: 36 bits physical, 48 bits virtual
   power management:
   processor	: 3
   vendor_id	: GenuineIntel
   cpu family	: 6
   model	: 42
   model name	: Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz
   stepping	: 7
   microcode	: 0x23
   cpu MHz	: 800.097
   cache size	: 8192 KB
   physical id	: 0
   siblings	: 8
   core id	: 1
   cpu cores	: 4
   apicid	: 3
   initial apicid	: 3
   fpu		: yes
   fpu_exception	: yes
   cpuid level	: 13
   wp		: yes
   bugs	:
   bogomips	: 4983.75
   clflush size: 64
   cache_alignment	: 64
   address sizes	: 36 bits physical, 48 bits virtual
   power management:

etienne@etienne-ThinkPad-W520: ~/Documents arch

   x86_64

etienne@etienne-ThinkPad-W520: ~/Documents cat /proc/meminfo

   MemTotal:        8128036 kB
   MemFree:         6533108 kB
   MemAvailable:    7010340 kB
   Buffers:           68588 kB
   Cached:           589804 kB
   SwapCached:            0 kB
   Active:          1032108 kB
   Inactive:         398668 kB
   Active(anon):     774636 kB
   Inactive(anon):    26916 kB
   Active(file):     257472 kB
   Inactive(file):   371752 kB
   Unevictable:          32 kB
   Mlocked:              32 kB
   SwapTotal:       3905532 kB
   SwapFree:        3905532 kB
   Dirty:               120 kB
   Writeback:             0 kB
   AnonPages:        772420 kB
   Mapped:           237016 kB
   Shmem:             29172 kB
   Slab:              66140 kB
   SReclaimable:      33900 kB
   SUnreclaim:        32240 kB
   KernelStack:        7648 kB
   PageTables:        26308 kB
   NFS_Unstable:          0 kB
   Bounce:                0 kB
   WritebackTmp:          0 kB
   CommitLimit:     7969548 kB
   Committed_AS:    3499748 kB
   VmallocTotal:   34359738367 kB
   VmallocUsed:      132284 kB
   VmallocChunk:   34359549692 kB
   HardwareCorrupted:     0 kB
   AnonHugePages:    188416 kB
   CmaTotal:              0 kB
   CmaFree:               0 kB
   HugePages_Total:       0
   HugePages_Free:        0
   HugePages_Rsvd:        0
   HugePages_Surp:        0
   Hugepagesize:       2048 kB
   DirectMap4k:      124544 kB
   DirectMap2M:     8216576 kB

etienne@etienne-ThinkPad-W520: ~/Documents lspci -t -v -nn

   -[0000:00]-+-00.0  Intel Corporation 2nd Generation Core Processor Family DRAM Controller [8086:0104]
          +-01.0-[01]--+-00.0  NVIDIA Corporation GF106GLM [Quadro 2000M] [10de:0dda]
          |            \-00.1  NVIDIA Corporation GF106 High Definition Audio Controller [10de:0be9]
          +-16.0  Intel Corporation 6 Series/C200 Series Chipset Family MEI Controller #1 [8086:1c3a]
          +-16.3  Intel Corporation 6 Series/C200 Series Chipset Family KT Controller [8086:1c3d]
          +-19.0  Intel Corporation 82579LM Gigabit Network Connection [8086:1502]
          +-1a.0  Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #2 [8086:1c2d]
          +-1b.0  Intel Corporation 6 Series/C200 Series Chipset Family High Definition Audio Controller [8086:1c20]
          +-1c.0-[02]--
          +-1c.1-[03]----00.0  Intel Corporation Centrino Ultimate-N 6300 [8086:4238]
          +-1c.3-[05-0c]--
          +-1c.4-[0d]--+-00.0  Ricoh Co Ltd PCIe SDXC/MMC Host Controller [1180:e823]
          |            \-00.3  Ricoh Co Ltd R5C832 PCIe IEEE 1394 Controller [1180:e832]
          +-1c.6-[0e]----00.0  NEC Corporation uPD720200 USB 3.0 Host Controller [1033:0194]
          +-1d.0  Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #1 [8086:1c26]
          +-1f.0  Intel Corporation QM67 Express Chipset Family LPC Controller [8086:1c4f]
          +-1f.2  Intel Corporation 6 Series/C200 Series Chipset Family 6 port SATA AHCI Controller [8086:1c03]
          \-1f.3  Intel Corporation 6 Series/C200 Series Chipset Family SMBus Controller [8086:1c22]

etienne@etienne-ThinkPad-W520: ~/Documents lsusb

   Bus 004 Device 003: ID 0bdb:1911 Ericsson Business Mobile Networks BV 
   Bus 004 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
   Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
   Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
   Bus 001 Device 002: ID 046d:c515 Logitech, Inc. Cordless 2.4 GHz Presenter Presentation remote control
   Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
   Bus 003 Device 006: ID 04f2:b217 Chicony Electronics Co., Ltd Lenovo Integrated Camera (0.3MP)
   Bus 003 Device 004: ID 147e:2016 Upek Biometric Touchchip/Touchstrip Fingerprint Sensor
   Bus 003 Device 003: ID 0765:5001 X-Rite, Inc. Huey PRO Colorimeter
   Bus 003 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub

I am running the Ubuntu version 14.04.3 LTS distribution of Linux. The running OS kernel is Linux 3.19.0-25-generic. My CPU is an Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz. It has 4 cores. The CPU architecture is x86_64: so 64-bit. The RAM is a bit more than 8Gb big. Connected to the PCI devices, there is some DRAM, the graphic card (Nvidia), some unknown controllers (MEI and KT), the Gigabit port card, 2 USB ports, Wireless card (Intel centrino), a SD card port, a Sata port. Regarding the USB devices, I can see the port for the sim card, the camera of the computer, the fingerprint sensor. The fdisk command did not output anything so I used cat /proc/partitions instead. It shows 7 partitions (+ one for the CD/DVD drive): 3 for Windows and 3 for Ubuntu. The screen shows a resolutions of minimum of 320 x 200, maximum 8192 x 8192. The currently used is 1920 x 1080. The wireless network interface is detected, as well as the Bluetooth device (after I turn it ON). The glxinfo command outputs something really long and not understandable. The computer has two audio cards: one buit-in from Intel, and one from Nvidia. Nvidia uses the bus 01.0/00.1 and the Intel one uses the bus 1b.0 The graphic controller is from Nvidia on bus 01.00/00.0 The Lenovo integrated camera is on bus 3. The wired network chipset is 82579LM Gigabit Network Connection from Intel. It is on bus 19.0 The wireless network chipset is Intel Centrino Ultimate-N 6300 on bus 1c.1. I cannot identify the bluetooth device. I think there is a cellular modem connected under "Ericsson Business Mobile Networks" on bus 4.


   1	def fib(n):
   2	    a,b = 1,1
   3	    for i in range(n-1):
   4	        a,b = b,a+b
   5	    return a


   2         0 LOAD_CONST               2 ((1, 1))	Constants of 1 and 1 are pushed onto the stack
             3 UNPACK_SEQUENCE          2		Unpacks the top-of-stack (TOS) into count individual values,

which are put onto the stack right-to-left

             6 STORE_FAST               1 (a)		Stores TOS into the local variable a
             9 STORE_FAST               2 (b)		Stores TOS into the local variable b
   3        12 SETUP_LOOP              41 (to 56)	Loop until line 56 is set up						
            15 LOAD_GLOBAL              0 (range)	Loads a global range for the loop
            18 LOAD_FAST                0 (n)		Pushes a reference to the local variable n onto the stack
            21 LOAD_CONST               1 (1)		Pushes the constant 1 onto the stack
            24 BINARY_SUBTRACT     			Implements TOS = TOS1 - TOS. Subtraction of (n-1)
            25 CALL_FUNCTION            1		Calls a function
            28 GET_ITER            			Implements the iteration on TOS
       >>   29 FOR_ITER                23 (to 55)	TOS is an operator and iteration is set up until line 55
            32 STORE_FAST               3 (i)		Stores TOS into local variable i
   4        35 LOAD_FAST                2 (b)		Pushes a reference to the local variable b onto the stack
            38 LOAD_FAST                1 (a)		Pushes a reference to the local variable a onto the stack
            41 LOAD_FAST                2 (b)		Pushes a reference to the local variable b onto the stack
            44 BINARY_ADD          			Implements TOS = TOS1 + TOS. Addition of (a+n)
            45 ROT_TWO             			Swaps the two top-most stack items. TOS1 = a+b. TOS = b
            46 STORE_FAST               1 (a)		Stores TOS into local variable a
            49 STORE_FAST               2 (b)		Stores TOS into local variable b
            52 JUMP_ABSOLUTE           29		Set bytecode counter to target
       >>   55 POP_BLOCK           			End of the iteration
   5   >>   56 LOAD_FAST                1 (a)		Pushes a reference to the local variable a onto the stack
            59 RETURN_VALUE        			Returns the value of TOS 

¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

   1
   2 def fib(n):
   3     a,b = 1,1
   4     for i in range(n-1):
   5         a,b = b,a+b
   6     return a

fib(3) => see below


   3         0 LOAD_CONST               2 ((1, 1))	Stack = [(1, 1)]
             3 UNPACK_SEQUENCE          2		Stack = [(1, 1)]
             6 STORE_FAST               1 (a)		Stack =[]; co_varnames = [a=1]
             9 STORE_FAST               2 (b)		Stack =[]; co_varnames = [a=1, b=1]
   4        12 SETUP_LOOP              41 (to 56)	Stack = []; loop is set up, counter is 1
            15 LOAD_GLOBAL              0 (range)	Stack = []
            18 LOAD_FAST                0 (n)		Stack = [n=3]
            21 LOAD_CONST               1 (1)		Stack = [1, n=3]
            24 BINARY_SUBTRACT     			Stack = [n-1=2]
            25 CALL_FUNCTION            1
            28 GET_ITER            
       >>   29 FOR_ITER                23 (to 55)	Iteration at 1
            32 STORE_FAST               3 (i)		Stack = []; co_varnames = [a=1, b=1, i=1]
   5        35 LOAD_FAST                2 (b)		Stack = [b=1]
            38 LOAD_FAST                1 (a)		Stack = [a=1, b=1]
            41 LOAD_FAST                2 (b)		Stack = [b=1, a=1, b=1]
            44 BINARY_ADD          			Stack = [b=1+a=1, b=1]
            45 ROT_TWO             			Stack = [b=1, 2]
            46 STORE_FAST               1 (a)		Stack = []; co_varnames = [a=1, b=1, i=1]
            49 STORE_FAST               2 (b)		Stack = []; co_varnames = [a=1, b=2, i=1]
            52 JUMP_ABSOLUTE           29		Jump to 29
       >>   29 FOR_ITER                23 (to 55)	Iteration at 2
            32 STORE_FAST               3 (i)		Stack = []; co_varnames = [a=1, b=2, i=2]
   5        35 LOAD_FAST                2 (b)		Stack = [b=2]
            38 LOAD_FAST                1 (a)		Stack = [a=1, b=1]
            41 LOAD_FAST                2 (b)		Stack = [b=2, a=1, b=2]
            44 BINARY_ADD          			Stack = [b=2+a=1, b=2]
            45 ROT_TWO             			Stack = [b=2, 3]
            46 STORE_FAST               1 (a)		Stack = []; co_varnames = [a=1, b=2, i=2]
            49 STORE_FAST               2 (b)		Stack = []; co_varnames = [a=2, b=3, i=2]
            52 JUMP_ABSOLUTE           29		Jump to 29
       >>   29 FOR_ITER                23 (to 55)	Iteration at 3 => jumps to instructions 55
       >>   55 POP_BLOCK           			Ends the loop
   6   >>   56 LOAD_FAST                1 (a)		Stack = [a=2]
            59 RETURN_VALUE     			Stack = [2]

   int fib(n) {
       int a = 1;
       int b = 1;
       int i;
       for (i = 0; i < n; i++) {
           int s = a + b;
           a = b;
           b = s;
       }
       return a;
   }


General code description

   fib:
       mov	r3, #1      /Copy constant #1 to register 3                  /Gives the constant value "1" to b in r3
       mov	r1, #0      /Copy constant #0 to register 1                  /Gives the constant value "0" to i in r1
       mov	r2, r3      /Copy value in register 3 to register 2          /Gives the value "1" of b to a in r2
       b	.L2         /Jump to .L2                                     /Jump to L2
   
   .L3:                                                                     /Execution of the loop operations
       add	ip, r2, r3  /ip = r2 + r3                                    /s(ip) = b(r3) + a(r2)
       add	r1, r1, #1  /r1 = r1 + constant #1                           /i(r1) = i(r1) + 1(#1)   this is the iteration i++
       mov	r2, r3      /copy r3 to r2                                   /b(r3) gives its value to a(r2)
       mov	r3, ip      /copy ip to r3                                   /s(ip) gives its value to b(r3)
   
   .L2:                                                                     /Condition of the loop
       cmp	r1, r0      /compare r0 against r1                           /Tells if i(r1) equals n (r0)
       blt	.L3         /jumps to .L3 if comparison above is "not equal" /jumps to .L3 if comparison above is "not equal"
       mov	r0, r2      /copy r2 to r0                                   /0 in r0 gets its value replaces by a(r2). This is the return statement
       bx	lr          /jump back to caller                             /

¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ With 3 as argument, step by step instructions

   fib:
       mov	r3, #1      /Gives the constant value "1" to b in r3
       mov	r1, #0      /Gives the constant value "0" to i in r1
       mov	r2, r3      /Gives the value "1" of b to a in r2
       b	.L2         /Jump to .L2
   
   .L2:                    /Loop
       cmp	r1, r0      /Tells if i=0(r1) equals n=3(r0)
       blt	.L3         /jumps to .L3 as comparison above is "not equal" 0!=3
   	
   .L3:                    /Execution of the loop operations
       add	ip, r2, r3  /s=2(ip) = b=1(r3) + a=1(r2)
       add	r1, r1, #1  /i=1(r1) = i=0(r1) + 1(#1)   this is the iteration i++
       mov	r2, r3      /b=1(r3) gives its value to a=1(r2)
       mov	r3, ip      /s=2(ip) gives its value to b=2(r3)
   
   .L2:                    /Loop
       cmp	r1, r0      /Tells if i=1(r1) equals n=3(r0)
       blt	.L3         /jumps to .L3 as comparison above is "not equal" 1!=3
   
   .L3:                    /Execution of the loop operations
       add	ip, r2, r3  /s=3(ip) = b=2(r3) + a=1(r2)
       add	r1, r1, #1  /i=2(r1) = i=1(r1) + 1(#1)   this is the iteration i++
       mov	r2, r3      /b=2(r3) gives its value to a=2(r2)
       mov	r3, ip      /s=3(ip) gives its value to b=3(r3)
   
   .L2:                    /Loop
       cmp	r1, r0      /Tells if i=2(r1) equals n=3(r0)
       blt	.L3         /jumps to .L3 as comparison above is "not equal" 2!=3
   
   .L3:                    /Execution of the loop operations
       add	ip, r2, r3  /s=5(ip) = b=3(r3) + a=2(r2)
       add	r1, r1, #1  /i=3(r1) = i=2(r1) + 1(#1)   this is the iteration i++
       mov	r2, r3      /b=3(r3) gives its value to a=3(r2)
       mov	r3, ip      /s=5(ip) gives its value to b=5(r3)
   
   .L2:                    /Loop
       cmp	r1, r0      /Tells if i=3(r1) equals n=3(r0) => 3=3 end of loop
       mov	r0, r2      /r0=3 gets its value from a=3(r2). This is the return statement.
       bx	lr          /

At this point the values left in registers are: r0=3, r1=3, r2=3, r3=5, ip=5