SlideShare a Scribd company logo
1 of 10
Download to read offline
Tugas 3 11516 Organisasi Sistem Komputer


Machine Level Programming and Assembly Language




                          oleh :
                I Putu Agus Eka Pratama
                        23510310



                        Dosen :
               Dr. Kusprasapta Mutijarsa




     Magister Teknologi Informasi
Sekolah Teknik Elektro dan Informatika
      Institut Teknologi Bandung
                  2011
1. Soal :
Practice problem 3.1
Assume the following values are stored at the indicated memory addresses and registers :
                              Address                           Value
                               0x100                                0xFF
                               0x104                            0xAB
                               0x108                                0x13
                               0x10C                                0x11


                              Address                           Value
                                %eax                            0x100
                                %ecx                                0x1
                                %edx                                0x3


Fill the following table showing the values for the indicated operands :
                              Operand                           Value
                  %eax
                  0x104                             0xAB
                  $0x108
                  (%eax)
                  4(%eax)


                              Operand                           Value
                  9(%eax,%edx)
                  260(%ecx,%edx)
                  0xFC(, %ecx,4)
                  (%eax,%edx,4)


Jawab :


 Operand        Value                          Keterangan
%eax           0x100     Nilai dari %eax adalah 0x100 (register).
0x104          0xAB      Nilai dari register 0x104 adalah 0xAB (absolut address).
$0x108         0x108     Tanda $ menyatakan bahwa data integer konstan sehingga
                         data tetap (immediate).
(%eax)         0xFF      %eax = 0x100, sehingga value 0xFF (address 0x100).
4(%eax)        0xAB       0x104 = 0x100 + 4 dan value 0xAB (address 0x104).


    Operand             Value                       Keterangan
9(%eax,%edx)           0x11     0x10C = (0x9 + 0x3) + 0x100 = C + 0x100 , value
                                0x11 (address 0x10C).
260(%ecx,%edx) 0x13             260 = 0x104.
                                0x104 + 0x1 + 0x3 = 0x108, value 0x13 (adress
                                0x108).
0xFC(, %ecx,4)         0xFF     0xFC + (1*4).
                                0xFC + 0x4 = 0x100 (address 0x100).
(%eax,%edx,4)          0x11     (0x1 * 4) + 0x100 = 0x10C, value 0x11 (address
                                0x10C).


   2. Soal :
[Practice Problem 3.2]
You are given the following information. A function with prototype void decode1(int *xp, int *yp, int
*zp); is compiled into assembly code. The body of the code is as follows:
1. movl 8(%ebp), %edi
2. movl 12(%ebp), %ebx
3. movl 16(%ebp), %esi
4. movl (%edi), %eax
5. movl (%ebx), %edx
6. movl (%esi), %ecx
7. movl %eax, (%ebx)
8. movl %edx, (%esi)
9. movl %ecx, (%edi)
Parameters xp, yp, and zp are stored at memory locations with offsets 8, 12, and 16, respectively,
relative to the address in register %ebp.
Write C code for decode1 that will have an effect equivalent to the assembly code above.
You can test your answer by compiling your code with the –S switch.
Your compiler may generate code that differs in the usage of registers or the ordering of memory
references, but is should still be functionally equivalent.


Jawab :
Code Assembly :
movl 8(%ebp), %edi
movl 12(%ebp), %ebx
movl 16(%ebp), %esi
movl (%edi), %eax
movl (%ebx), %edx
movl (%esi), %ecx
movl %eax, (%ebx)
movl %edx, (%esi)
movl %ecx, (%edi)


void decode1(int *xp, int *yp, int *zp);


Code C :
void decode1(int *xp, int *yp, int *zp)
{
int tx = *xp;
int ty = *yp;
int tz = *zp;
*yp = tx;
*zp = ty;
*xp = tz;
}


Pembuktian :
Membuat file jawabansoalno2.c
putu-shinoda@my-machine:~$ touch jawabansoalno2.c
Mengisikan script C ke dalam file jawabansoalno2.c
putu-shinoda@my-machine:~$ nano jawabansoalno2.c
Kode C yang dimasukkan
void decode1(int *xp, int *yp, int *zp)
{
int tx = *xp;
int ty = *yp;
int tz = *zp;
*yp = tx;
*zp = ty;
*xp = tz;
}
Ditampilkan pada gambar berikut
Kemudian dilanjutkan mencompile file jawabansoalno2.c dengan opsi -S
putu-shinoda@my-machine:~$ gcc -O -S jawabansoalno2.c
Terbentuk file jawabansoalno2.s dengan isi file sebagai berikut
3. Soal :
[Practice Problem 3.3]
Suppose register %eax holds value x and %ecx holds value y. Fill in the table below with formulas
indicating the value that will be stored in register %edx for each of the following assembly code
instructions.
                        Expression                             Result
      leal 6(%eax), %edx
      leal (%eax, %ecx), %edx
      leal (%eax, %ecx,4)


                        Expression                             Result
      leal 7(%eax, %eax,8), %edx
      leal 0xA(,%ecx, 4), %edx
      leal 9(%eax, %ecx,2),%edx


Jawab :


          Expression                 Result                       Keterangan
leal 6(%eax), %edx              6+x           %edx = 6 + x.
leal (%eax, %ecx), %edx         X+y           %edx = x + y.
leal (%eax, %ecx,4), %edx       X + 4y        %edx = x + 4y.


          Expression                 Result                       Keterangan
leal 7(%eax, %eax,8), %edx      7 + 9x        %edx = 7 + x + (8*x) = 7 + 9x.
leal 0xA(,%ecx, 4), %edx        10 + 4y       0xA = 10.
                                              %edx = 10 + (y*4) = 10 + 4y.
leal 9(%eax, %ecx,2), %edx      9 + x + 2y    %edx = 9 + x + (2*y) = 9 + x + 2y.


   4. Soal :
[Practice Problem 3.4]
Assume the following values are stored at the indicated memory addresses and registers :
                         Address                               Value
                0x100                         0xFF
                0x104                         0xAB
                0x108                         0x13
0x10C                          0x11


                        Address                              Value
             %eax                           0x100
             %ecx                           0x1
             %edx                           0x3


Fill in the following table showing the effects of the following instructions, both in terms of the
register or memory location that will be updated and the resulting value.
            Instruksi                         Tujuan                            Nilai
add1 %ecx, (%eax)                 0x100
sub1 %edx, 4 (%eax)
Imu11 $16 (%eax, %edx, 4)
Inc1 8 (%eax)
dec1 %ecx
sub1 %edx, %eax


Jawab :
            Instruksi                         Tujuan                            Nilai
add1 %ecx, (%eax)                 0x100                              0x100
sub1 %edx, 4 (%eax)               0x104                              0xA8
Imu11 $16 (%eax, %edx, 4)         0x10C                              0x110
Inc1 8 (%eax)                     0x108                              0x14
dec1 %ecx                         %ecx                               0x0
sub1 %edx, %eax                   %eax                               0xFD


   5. Soal :
[Problem 3.31]
You are given the information that follows. A function with prototype void decode2(int x, int y, int
z); is compiled into assembly code. The body of the code is as follows:
1.movl 16(%ebp), %eax
2.movl 12(%ebp), %edx
3.sub %eax, %edx;
4.movl %edx, %eax
5.imull 8(%ebp), %edx
6.sall $31, %eax
7.sarl $31, %eax
8.xorl %edx, %eax
#C Code
int decode2(int x, int y, int z)
{
int t1 = y - z;
int t2 = x * t1;
int t3 = (t1 << 31) >> 31;
int t4 = t3 ˆ t2;
return t4;
}
Parameters x, y, and z are stored at memory locations with offsets 8, 12, and 16 relative to the
address in register %ebp. The code stores the return value in register %eax.
Write C code for decode2 that will have an effect equivalent to the assembly code. You can test your
answer by compiling your code with the –S switch. Your compiler may not generate identical code,
but it should be functionally equivalent.


Jawab :
Membuat file jawabansoalno5.c
putu-shinoda@my-machine:~$ touch jawabansoalno5.c
Mengisikan script C ke dalam file jawabansoalno5.c
putu-shinoda@my-machine:~$ nano jawabansoalno5.c
Kode C yang dimasukkan
int decode2(int x, int y, int z)
{
int t1 = y - z;
int t2 = x * t1;
int t3 = (t1 << 31) >> 31;
int t4 = t3 ˆ t2;
return t4;
}
Ditampilkan pada gambar berikut
Kemudian dilanjutkan mencompile file jawabansoalno5.c dengan opsi -S
putu-shinoda@my-machine:~$ gcc -O -S jawabansoalno5.c
Terbentuk file jawabansoalno5.s dengan isi file sebagai berikut
Tugas 3 oganisasi komputer 23510310

More Related Content

What's hot

Useful functions for arrays in php
Useful functions for arrays in phpUseful functions for arrays in php
Useful functions for arrays in phpChetan Patel
 
Using arrays with PHP for forms and storing information
Using arrays with PHP for forms and storing informationUsing arrays with PHP for forms and storing information
Using arrays with PHP for forms and storing informationNicole Ryan
 
Ecto DSL Introduction - Yurii Bodarev
Ecto DSL Introduction - Yurii BodarevEcto DSL Introduction - Yurii Bodarev
Ecto DSL Introduction - Yurii BodarevElixir Club
 
Airline reservation project using JAVA in NetBeans IDE
Airline reservation project using JAVA in NetBeans IDEAirline reservation project using JAVA in NetBeans IDE
Airline reservation project using JAVA in NetBeans IDEHimanshiSingh71
 
RxSwift 시작하기
RxSwift 시작하기RxSwift 시작하기
RxSwift 시작하기Suyeol Jeon
 
かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版Yutaka Kato
 
関数潮流(Function Tendency)
関数潮流(Function Tendency)関数潮流(Function Tendency)
関数潮流(Function Tendency)riue
 
Ruby Language - A quick tour
Ruby Language - A quick tourRuby Language - A quick tour
Ruby Language - A quick touraztack
 
PHP and MySQL Tips and tricks, DC 2007
PHP and MySQL Tips and tricks, DC 2007PHP and MySQL Tips and tricks, DC 2007
PHP and MySQL Tips and tricks, DC 2007Damien Seguy
 
Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기
Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기
Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기Suyeol Jeon
 
The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212Mahmoud Samir Fayed
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applicationsSkills Matter
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodecamp Romania
 
Using Scala Slick at FortyTwo
Using Scala Slick at FortyTwoUsing Scala Slick at FortyTwo
Using Scala Slick at FortyTwoEishay Smith
 

What's hot (20)

Useful functions for arrays in php
Useful functions for arrays in phpUseful functions for arrays in php
Useful functions for arrays in php
 
Using arrays with PHP for forms and storing information
Using arrays with PHP for forms and storing informationUsing arrays with PHP for forms and storing information
Using arrays with PHP for forms and storing information
 
Ecto DSL Introduction - Yurii Bodarev
Ecto DSL Introduction - Yurii BodarevEcto DSL Introduction - Yurii Bodarev
Ecto DSL Introduction - Yurii Bodarev
 
Airline reservation project using JAVA in NetBeans IDE
Airline reservation project using JAVA in NetBeans IDEAirline reservation project using JAVA in NetBeans IDE
Airline reservation project using JAVA in NetBeans IDE
 
RxSwift 시작하기
RxSwift 시작하기RxSwift 시작하기
RxSwift 시작하기
 
かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版
 
関数潮流(Function Tendency)
関数潮流(Function Tendency)関数潮流(Function Tendency)
関数潮流(Function Tendency)
 
Ruby Language - A quick tour
Ruby Language - A quick tourRuby Language - A quick tour
Ruby Language - A quick tour
 
PHP and MySQL Tips and tricks, DC 2007
PHP and MySQL Tips and tricks, DC 2007PHP and MySQL Tips and tricks, DC 2007
PHP and MySQL Tips and tricks, DC 2007
 
7li7w devcon5
7li7w devcon57li7w devcon5
7li7w devcon5
 
Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기
Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기
Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기
 
Begin with Python
Begin with PythonBegin with Python
Begin with Python
 
The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applications
 
Fp java8
Fp java8Fp java8
Fp java8
 
Python speleology
Python speleologyPython speleology
Python speleology
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
 
ddd+scala
ddd+scaladdd+scala
ddd+scala
 
Using Scala Slick at FortyTwo
Using Scala Slick at FortyTwoUsing Scala Slick at FortyTwo
Using Scala Slick at FortyTwo
 
20100528
2010052820100528
20100528
 

Viewers also liked

Vega open-source-pentest-di-linux
Vega open-source-pentest-di-linuxVega open-source-pentest-di-linux
Vega open-source-pentest-di-linuxPutu Shinoda
 
ICCSN - EII 2012 English version
ICCSN - EII 2012 English versionICCSN - EII 2012 English version
ICCSN - EII 2012 English versionPutu Shinoda
 
23510310 tugas meaningful broadband
23510310   tugas meaningful broadband23510310   tugas meaningful broadband
23510310 tugas meaningful broadbandPutu Shinoda
 
Sap service engineering
Sap service engineeringSap service engineering
Sap service engineeringPutu Shinoda
 
Paper UAS PSTI - I Putu Agus Eka Pratama - Bank Danamon
Paper UAS PSTI - I Putu Agus Eka Pratama -  Bank DanamonPaper UAS PSTI - I Putu Agus Eka Pratama -  Bank Danamon
Paper UAS PSTI - I Putu Agus Eka Pratama - Bank DanamonPutu Shinoda
 
Instalasi cms formulasi di linux
Instalasi cms formulasi di linuxInstalasi cms formulasi di linux
Instalasi cms formulasi di linuxPutu Shinoda
 
Software requirementsspecification aplikasi logistik alat tulis kantor
Software requirementsspecification aplikasi logistik alat tulis kantorSoftware requirementsspecification aplikasi logistik alat tulis kantor
Software requirementsspecification aplikasi logistik alat tulis kantorPutu Shinoda
 
23510310 tugas essay 1
23510310   tugas essay 1 23510310   tugas essay 1
23510310 tugas essay 1 Putu Shinoda
 
Belajar erlang-di-linux
Belajar erlang-di-linuxBelajar erlang-di-linux
Belajar erlang-di-linuxPutu Shinoda
 
Sap jaringan komputer
Sap jaringan komputerSap jaringan komputer
Sap jaringan komputerPutu Shinoda
 
Sap jaringan komputer
Sap jaringan komputerSap jaringan komputer
Sap jaringan komputerPutu Shinoda
 
Install eclipse-linux
Install eclipse-linuxInstall eclipse-linux
Install eclipse-linuxPutu Shinoda
 
Install Netbeans dan JDK di Linux
Install Netbeans dan JDK di LinuxInstall Netbeans dan JDK di Linux
Install Netbeans dan JDK di LinuxPutu Shinoda
 
Seminar Open Year With Open Source Unikom Bandung 18 Januari 2014
Seminar Open Year With Open Source Unikom Bandung 18 Januari 2014Seminar Open Year With Open Source Unikom Bandung 18 Januari 2014
Seminar Open Year With Open Source Unikom Bandung 18 Januari 2014Putu Shinoda
 
Paper uts 23510310_i_putuagusekapratama_bankdanamon
Paper uts 23510310_i_putuagusekapratama_bankdanamonPaper uts 23510310_i_putuagusekapratama_bankdanamon
Paper uts 23510310_i_putuagusekapratama_bankdanamonPutu Shinoda
 
NDN SIM (Named Data Networking Simulator)
NDN SIM (Named Data Networking Simulator)NDN SIM (Named Data Networking Simulator)
NDN SIM (Named Data Networking Simulator)Putu Shinoda
 
Resume eii 2012 itb
Resume eii 2012 itbResume eii 2012 itb
Resume eii 2012 itbPutu Shinoda
 
Seminar security Smart City dan sampul buku
Seminar security Smart City dan sampul bukuSeminar security Smart City dan sampul buku
Seminar security Smart City dan sampul bukuPutu Shinoda
 

Viewers also liked (20)

Vega open-source-pentest-di-linux
Vega open-source-pentest-di-linuxVega open-source-pentest-di-linux
Vega open-source-pentest-di-linux
 
ICCSN - EII 2012 English version
ICCSN - EII 2012 English versionICCSN - EII 2012 English version
ICCSN - EII 2012 English version
 
23510310 tugas meaningful broadband
23510310   tugas meaningful broadband23510310   tugas meaningful broadband
23510310 tugas meaningful broadband
 
Sap service engineering
Sap service engineeringSap service engineering
Sap service engineering
 
Paper UAS PSTI - I Putu Agus Eka Pratama - Bank Danamon
Paper UAS PSTI - I Putu Agus Eka Pratama -  Bank DanamonPaper UAS PSTI - I Putu Agus Eka Pratama -  Bank Danamon
Paper UAS PSTI - I Putu Agus Eka Pratama - Bank Danamon
 
Instalasi cms formulasi di linux
Instalasi cms formulasi di linuxInstalasi cms formulasi di linux
Instalasi cms formulasi di linux
 
Software requirementsspecification aplikasi logistik alat tulis kantor
Software requirementsspecification aplikasi logistik alat tulis kantorSoftware requirementsspecification aplikasi logistik alat tulis kantor
Software requirementsspecification aplikasi logistik alat tulis kantor
 
23510310 tugas essay 1
23510310   tugas essay 1 23510310   tugas essay 1
23510310 tugas essay 1
 
Kenang - kenangan
Kenang - kenanganKenang - kenangan
Kenang - kenangan
 
Belajar erlang-di-linux
Belajar erlang-di-linuxBelajar erlang-di-linux
Belajar erlang-di-linux
 
Sap jaringan komputer
Sap jaringan komputerSap jaringan komputer
Sap jaringan komputer
 
Sap jaringan komputer
Sap jaringan komputerSap jaringan komputer
Sap jaringan komputer
 
Install eclipse-linux
Install eclipse-linuxInstall eclipse-linux
Install eclipse-linux
 
Install Netbeans dan JDK di Linux
Install Netbeans dan JDK di LinuxInstall Netbeans dan JDK di Linux
Install Netbeans dan JDK di Linux
 
Seminar Open Year With Open Source Unikom Bandung 18 Januari 2014
Seminar Open Year With Open Source Unikom Bandung 18 Januari 2014Seminar Open Year With Open Source Unikom Bandung 18 Januari 2014
Seminar Open Year With Open Source Unikom Bandung 18 Januari 2014
 
Paper uts 23510310_i_putuagusekapratama_bankdanamon
Paper uts 23510310_i_putuagusekapratama_bankdanamonPaper uts 23510310_i_putuagusekapratama_bankdanamon
Paper uts 23510310_i_putuagusekapratama_bankdanamon
 
NDN SIM (Named Data Networking Simulator)
NDN SIM (Named Data Networking Simulator)NDN SIM (Named Data Networking Simulator)
NDN SIM (Named Data Networking Simulator)
 
Report kelompok
Report kelompokReport kelompok
Report kelompok
 
Resume eii 2012 itb
Resume eii 2012 itbResume eii 2012 itb
Resume eii 2012 itb
 
Seminar security Smart City dan sampul buku
Seminar security Smart City dan sampul bukuSeminar security Smart City dan sampul buku
Seminar security Smart City dan sampul buku
 

Similar to Tugas 3 oganisasi komputer 23510310

INTRODUCTION TO MATLAB session with notes
  INTRODUCTION TO MATLAB   session with  notes  INTRODUCTION TO MATLAB   session with  notes
INTRODUCTION TO MATLAB session with notesInfinity Tech Solutions
 
Basic R Data Manipulation
Basic R Data ManipulationBasic R Data Manipulation
Basic R Data ManipulationChu An
 
Gabriele Lana - The Magic of Elixir
Gabriele Lana - The Magic of ElixirGabriele Lana - The Magic of Elixir
Gabriele Lana - The Magic of ElixirCodemotion
 
Yurii Bodarev - Ecto DSL
Yurii Bodarev - Ecto DSLYurii Bodarev - Ecto DSL
Yurii Bodarev - Ecto DSLElixir Club
 
Arrays and addressing modes
Arrays and addressing modesArrays and addressing modes
Arrays and addressing modesBilal Amjad
 
Presentation R basic teaching module
Presentation R basic teaching modulePresentation R basic teaching module
Presentation R basic teaching moduleSander Timmer
 
Taylor and maclaurian series
Taylor and maclaurian seriesTaylor and maclaurian series
Taylor and maclaurian seriesNishant Patel
 
Lecture 3 and 4.pptx
Lecture 3 and 4.pptxLecture 3 and 4.pptx
Lecture 3 and 4.pptxMAHAMASADIK
 
0.0. punto fijo
0.0. punto fijo0.0. punto fijo
0.0. punto fijoAgua SAC
 
Use the same variable names and write the function F - Force(x-ks-kc-l.pdf
Use the same variable names and write the function F - Force(x-ks-kc-l.pdfUse the same variable names and write the function F - Force(x-ks-kc-l.pdf
Use the same variable names and write the function F - Force(x-ks-kc-l.pdfacteleshoppe
 
Module II Partition and Generating Function (2).ppt
Module II Partition and Generating Function (2).pptModule II Partition and Generating Function (2).ppt
Module II Partition and Generating Function (2).pptssuser26e219
 
Please use the same variables and only write the TODO part #!-usr-bi.pdf
Please use the same variables and only write the TODO part   #!-usr-bi.pdfPlease use the same variables and only write the TODO part   #!-usr-bi.pdf
Please use the same variables and only write the TODO part #!-usr-bi.pdfasenterprisestyagi
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabkrishna_093
 

Similar to Tugas 3 oganisasi komputer 23510310 (20)

INTRODUCTION TO MATLAB session with notes
  INTRODUCTION TO MATLAB   session with  notes  INTRODUCTION TO MATLAB   session with  notes
INTRODUCTION TO MATLAB session with notes
 
Basic R Data Manipulation
Basic R Data ManipulationBasic R Data Manipulation
Basic R Data Manipulation
 
Gabriele Lana - The Magic of Elixir
Gabriele Lana - The Magic of ElixirGabriele Lana - The Magic of Elixir
Gabriele Lana - The Magic of Elixir
 
bobok
bobokbobok
bobok
 
The Magic Of Elixir
The Magic Of ElixirThe Magic Of Elixir
The Magic Of Elixir
 
Yurii Bodarev - Ecto DSL
Yurii Bodarev - Ecto DSLYurii Bodarev - Ecto DSL
Yurii Bodarev - Ecto DSL
 
Arrays and addressing modes
Arrays and addressing modesArrays and addressing modes
Arrays and addressing modes
 
Presentation R basic teaching module
Presentation R basic teaching modulePresentation R basic teaching module
Presentation R basic teaching module
 
W 9 numbering system
W 9 numbering systemW 9 numbering system
W 9 numbering system
 
W 9 numbering system
W 9 numbering systemW 9 numbering system
W 9 numbering system
 
1.2 matlab numerical data
1.2  matlab numerical data1.2  matlab numerical data
1.2 matlab numerical data
 
Taylor and maclaurian series
Taylor and maclaurian seriesTaylor and maclaurian series
Taylor and maclaurian series
 
Elixir and OTP Apps introduction
Elixir and OTP Apps introductionElixir and OTP Apps introduction
Elixir and OTP Apps introduction
 
Lecture 3 and 4.pptx
Lecture 3 and 4.pptxLecture 3 and 4.pptx
Lecture 3 and 4.pptx
 
MATLAB Programming
MATLAB Programming MATLAB Programming
MATLAB Programming
 
0.0. punto fijo
0.0. punto fijo0.0. punto fijo
0.0. punto fijo
 
Use the same variable names and write the function F - Force(x-ks-kc-l.pdf
Use the same variable names and write the function F - Force(x-ks-kc-l.pdfUse the same variable names and write the function F - Force(x-ks-kc-l.pdf
Use the same variable names and write the function F - Force(x-ks-kc-l.pdf
 
Module II Partition and Generating Function (2).ppt
Module II Partition and Generating Function (2).pptModule II Partition and Generating Function (2).ppt
Module II Partition and Generating Function (2).ppt
 
Please use the same variables and only write the TODO part #!-usr-bi.pdf
Please use the same variables and only write the TODO part   #!-usr-bi.pdfPlease use the same variables and only write the TODO part   #!-usr-bi.pdf
Please use the same variables and only write the TODO part #!-usr-bi.pdf
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 

More from Putu Shinoda

ipae-cybersecurityindustri40-bapeten.pdf
ipae-cybersecurityindustri40-bapeten.pdfipae-cybersecurityindustri40-bapeten.pdf
ipae-cybersecurityindustri40-bapeten.pdfPutu Shinoda
 
Linux, Ubuntu, FOSS, dan Smart City
Linux, Ubuntu, FOSS, dan Smart CityLinux, Ubuntu, FOSS, dan Smart City
Linux, Ubuntu, FOSS, dan Smart CityPutu Shinoda
 
Seminar Intelligent Trasport System (ITS) Univ Telkom
Seminar Intelligent Trasport System (ITS) Univ TelkomSeminar Intelligent Trasport System (ITS) Univ Telkom
Seminar Intelligent Trasport System (ITS) Univ TelkomPutu Shinoda
 
Seminar Linux Ubuntu, Pemanfaatannya, dan Smart City
Seminar Linux Ubuntu, Pemanfaatannya, dan Smart CitySeminar Linux Ubuntu, Pemanfaatannya, dan Smart City
Seminar Linux Ubuntu, Pemanfaatannya, dan Smart CityPutu Shinoda
 
Materi Kuliah Kapita Selekta 3 : OTT
Materi Kuliah Kapita Selekta 3 : OTTMateri Kuliah Kapita Selekta 3 : OTT
Materi Kuliah Kapita Selekta 3 : OTTPutu Shinoda
 
Materi Kuliah Umum Kapita Selekta : Internet Of Things
Materi Kuliah Umum Kapita Selekta : Internet Of ThingsMateri Kuliah Umum Kapita Selekta : Internet Of Things
Materi Kuliah Umum Kapita Selekta : Internet Of ThingsPutu Shinoda
 
Kuliah Umum 1 Kapita Selekta Univ Telkom : Smart City.
Kuliah Umum 1 Kapita Selekta Univ Telkom : Smart City.Kuliah Umum 1 Kapita Selekta Univ Telkom : Smart City.
Kuliah Umum 1 Kapita Selekta Univ Telkom : Smart City.Putu Shinoda
 
Seminar Linux Dan Smart City Telkom University Mei 2014
Seminar Linux Dan Smart City Telkom University Mei 2014Seminar Linux Dan Smart City Telkom University Mei 2014
Seminar Linux Dan Smart City Telkom University Mei 2014Putu Shinoda
 
Seminar Linux dan Android Legian Cafe Dago Bandung 15 Maret 2014 (2)
Seminar Linux dan Android Legian Cafe Dago Bandung 15 Maret 2014 (2)Seminar Linux dan Android Legian Cafe Dago Bandung 15 Maret 2014 (2)
Seminar Linux dan Android Legian Cafe Dago Bandung 15 Maret 2014 (2)Putu Shinoda
 
Seminar Linux dan Android Legian Cafe Dago Bandung 15 Maret 2014 (1)
Seminar Linux dan Android Legian Cafe Dago Bandung 15 Maret 2014 (1)Seminar Linux dan Android Legian Cafe Dago Bandung 15 Maret 2014 (1)
Seminar Linux dan Android Legian Cafe Dago Bandung 15 Maret 2014 (1)Putu Shinoda
 
Putu smartcity 22 feb 2014
Putu smartcity 22 feb 2014Putu smartcity 22 feb 2014
Putu smartcity 22 feb 2014Putu Shinoda
 
Pertemuan 1 sistem operasi S1 sistem komputer univ telkom 2014
Pertemuan 1 sistem operasi S1 sistem komputer univ telkom 2014Pertemuan 1 sistem operasi S1 sistem komputer univ telkom 2014
Pertemuan 1 sistem operasi S1 sistem komputer univ telkom 2014Putu Shinoda
 
Information and social network 1
Information and social network 1Information and social network 1
Information and social network 1Putu Shinoda
 
Presentasi putu-unikom-180114
Presentasi putu-unikom-180114Presentasi putu-unikom-180114
Presentasi putu-unikom-180114Putu Shinoda
 
Slide Jaringan Komputer ITB pertemuan 1
Slide Jaringan Komputer ITB pertemuan 1 Slide Jaringan Komputer ITB pertemuan 1
Slide Jaringan Komputer ITB pertemuan 1 Putu Shinoda
 
Micro Teaching Mata Kuliah Jaringan Komputer IT Telkom 2013
Micro Teaching Mata Kuliah Jaringan Komputer IT Telkom 2013Micro Teaching Mata Kuliah Jaringan Komputer IT Telkom 2013
Micro Teaching Mata Kuliah Jaringan Komputer IT Telkom 2013Putu Shinoda
 

More from Putu Shinoda (20)

ipae-cybersecurityindustri40-bapeten.pdf
ipae-cybersecurityindustri40-bapeten.pdfipae-cybersecurityindustri40-bapeten.pdf
ipae-cybersecurityindustri40-bapeten.pdf
 
Linux, Ubuntu, FOSS, dan Smart City
Linux, Ubuntu, FOSS, dan Smart CityLinux, Ubuntu, FOSS, dan Smart City
Linux, Ubuntu, FOSS, dan Smart City
 
Seminar Intelligent Trasport System (ITS) Univ Telkom
Seminar Intelligent Trasport System (ITS) Univ TelkomSeminar Intelligent Trasport System (ITS) Univ Telkom
Seminar Intelligent Trasport System (ITS) Univ Telkom
 
Seminar Linux Ubuntu, Pemanfaatannya, dan Smart City
Seminar Linux Ubuntu, Pemanfaatannya, dan Smart CitySeminar Linux Ubuntu, Pemanfaatannya, dan Smart City
Seminar Linux Ubuntu, Pemanfaatannya, dan Smart City
 
Web Security
Web SecurityWeb Security
Web Security
 
Materi Kuliah Kapita Selekta 3 : OTT
Materi Kuliah Kapita Selekta 3 : OTTMateri Kuliah Kapita Selekta 3 : OTT
Materi Kuliah Kapita Selekta 3 : OTT
 
Materi Kuliah Umum Kapita Selekta : Internet Of Things
Materi Kuliah Umum Kapita Selekta : Internet Of ThingsMateri Kuliah Umum Kapita Selekta : Internet Of Things
Materi Kuliah Umum Kapita Selekta : Internet Of Things
 
Kuliah Umum 1 Kapita Selekta Univ Telkom : Smart City.
Kuliah Umum 1 Kapita Selekta Univ Telkom : Smart City.Kuliah Umum 1 Kapita Selekta Univ Telkom : Smart City.
Kuliah Umum 1 Kapita Selekta Univ Telkom : Smart City.
 
Seminar Linux Dan Smart City Telkom University Mei 2014
Seminar Linux Dan Smart City Telkom University Mei 2014Seminar Linux Dan Smart City Telkom University Mei 2014
Seminar Linux Dan Smart City Telkom University Mei 2014
 
Seminar Linux dan Android Legian Cafe Dago Bandung 15 Maret 2014 (2)
Seminar Linux dan Android Legian Cafe Dago Bandung 15 Maret 2014 (2)Seminar Linux dan Android Legian Cafe Dago Bandung 15 Maret 2014 (2)
Seminar Linux dan Android Legian Cafe Dago Bandung 15 Maret 2014 (2)
 
Seminar Linux dan Android Legian Cafe Dago Bandung 15 Maret 2014 (1)
Seminar Linux dan Android Legian Cafe Dago Bandung 15 Maret 2014 (1)Seminar Linux dan Android Legian Cafe Dago Bandung 15 Maret 2014 (1)
Seminar Linux dan Android Legian Cafe Dago Bandung 15 Maret 2014 (1)
 
Putu smartcity 22 feb 2014
Putu smartcity 22 feb 2014Putu smartcity 22 feb 2014
Putu smartcity 22 feb 2014
 
Pertemuan 1 sistem operasi S1 sistem komputer univ telkom 2014
Pertemuan 1 sistem operasi S1 sistem komputer univ telkom 2014Pertemuan 1 sistem operasi S1 sistem komputer univ telkom 2014
Pertemuan 1 sistem operasi S1 sistem komputer univ telkom 2014
 
Information and social network 1
Information and social network 1Information and social network 1
Information and social network 1
 
Presentasi putu-unikom-180114
Presentasi putu-unikom-180114Presentasi putu-unikom-180114
Presentasi putu-unikom-180114
 
Ist service-4
Ist service-4Ist service-4
Ist service-4
 
Ist service-2
Ist service-2Ist service-2
Ist service-2
 
Ist service-1
Ist service-1Ist service-1
Ist service-1
 
Slide Jaringan Komputer ITB pertemuan 1
Slide Jaringan Komputer ITB pertemuan 1 Slide Jaringan Komputer ITB pertemuan 1
Slide Jaringan Komputer ITB pertemuan 1
 
Micro Teaching Mata Kuliah Jaringan Komputer IT Telkom 2013
Micro Teaching Mata Kuliah Jaringan Komputer IT Telkom 2013Micro Teaching Mata Kuliah Jaringan Komputer IT Telkom 2013
Micro Teaching Mata Kuliah Jaringan Komputer IT Telkom 2013
 

Recently uploaded

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Recently uploaded (20)

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

Tugas 3 oganisasi komputer 23510310

  • 1. Tugas 3 11516 Organisasi Sistem Komputer Machine Level Programming and Assembly Language oleh : I Putu Agus Eka Pratama 23510310 Dosen : Dr. Kusprasapta Mutijarsa Magister Teknologi Informasi Sekolah Teknik Elektro dan Informatika Institut Teknologi Bandung 2011
  • 2. 1. Soal : Practice problem 3.1 Assume the following values are stored at the indicated memory addresses and registers : Address Value 0x100 0xFF 0x104 0xAB 0x108 0x13 0x10C 0x11 Address Value %eax 0x100 %ecx 0x1 %edx 0x3 Fill the following table showing the values for the indicated operands : Operand Value %eax 0x104 0xAB $0x108 (%eax) 4(%eax) Operand Value 9(%eax,%edx) 260(%ecx,%edx) 0xFC(, %ecx,4) (%eax,%edx,4) Jawab : Operand Value Keterangan %eax 0x100 Nilai dari %eax adalah 0x100 (register). 0x104 0xAB Nilai dari register 0x104 adalah 0xAB (absolut address). $0x108 0x108 Tanda $ menyatakan bahwa data integer konstan sehingga data tetap (immediate). (%eax) 0xFF %eax = 0x100, sehingga value 0xFF (address 0x100).
  • 3. 4(%eax) 0xAB 0x104 = 0x100 + 4 dan value 0xAB (address 0x104). Operand Value Keterangan 9(%eax,%edx) 0x11 0x10C = (0x9 + 0x3) + 0x100 = C + 0x100 , value 0x11 (address 0x10C). 260(%ecx,%edx) 0x13 260 = 0x104. 0x104 + 0x1 + 0x3 = 0x108, value 0x13 (adress 0x108). 0xFC(, %ecx,4) 0xFF 0xFC + (1*4). 0xFC + 0x4 = 0x100 (address 0x100). (%eax,%edx,4) 0x11 (0x1 * 4) + 0x100 = 0x10C, value 0x11 (address 0x10C). 2. Soal : [Practice Problem 3.2] You are given the following information. A function with prototype void decode1(int *xp, int *yp, int *zp); is compiled into assembly code. The body of the code is as follows: 1. movl 8(%ebp), %edi 2. movl 12(%ebp), %ebx 3. movl 16(%ebp), %esi 4. movl (%edi), %eax 5. movl (%ebx), %edx 6. movl (%esi), %ecx 7. movl %eax, (%ebx) 8. movl %edx, (%esi) 9. movl %ecx, (%edi) Parameters xp, yp, and zp are stored at memory locations with offsets 8, 12, and 16, respectively, relative to the address in register %ebp. Write C code for decode1 that will have an effect equivalent to the assembly code above. You can test your answer by compiling your code with the –S switch. Your compiler may generate code that differs in the usage of registers or the ordering of memory references, but is should still be functionally equivalent. Jawab : Code Assembly : movl 8(%ebp), %edi movl 12(%ebp), %ebx
  • 4. movl 16(%ebp), %esi movl (%edi), %eax movl (%ebx), %edx movl (%esi), %ecx movl %eax, (%ebx) movl %edx, (%esi) movl %ecx, (%edi) void decode1(int *xp, int *yp, int *zp); Code C : void decode1(int *xp, int *yp, int *zp) { int tx = *xp; int ty = *yp; int tz = *zp; *yp = tx; *zp = ty; *xp = tz; } Pembuktian : Membuat file jawabansoalno2.c putu-shinoda@my-machine:~$ touch jawabansoalno2.c Mengisikan script C ke dalam file jawabansoalno2.c putu-shinoda@my-machine:~$ nano jawabansoalno2.c Kode C yang dimasukkan void decode1(int *xp, int *yp, int *zp) { int tx = *xp; int ty = *yp; int tz = *zp; *yp = tx; *zp = ty; *xp = tz; } Ditampilkan pada gambar berikut
  • 5. Kemudian dilanjutkan mencompile file jawabansoalno2.c dengan opsi -S putu-shinoda@my-machine:~$ gcc -O -S jawabansoalno2.c Terbentuk file jawabansoalno2.s dengan isi file sebagai berikut
  • 6. 3. Soal : [Practice Problem 3.3] Suppose register %eax holds value x and %ecx holds value y. Fill in the table below with formulas indicating the value that will be stored in register %edx for each of the following assembly code instructions. Expression Result leal 6(%eax), %edx leal (%eax, %ecx), %edx leal (%eax, %ecx,4) Expression Result leal 7(%eax, %eax,8), %edx leal 0xA(,%ecx, 4), %edx leal 9(%eax, %ecx,2),%edx Jawab : Expression Result Keterangan leal 6(%eax), %edx 6+x %edx = 6 + x. leal (%eax, %ecx), %edx X+y %edx = x + y. leal (%eax, %ecx,4), %edx X + 4y %edx = x + 4y. Expression Result Keterangan leal 7(%eax, %eax,8), %edx 7 + 9x %edx = 7 + x + (8*x) = 7 + 9x. leal 0xA(,%ecx, 4), %edx 10 + 4y 0xA = 10. %edx = 10 + (y*4) = 10 + 4y. leal 9(%eax, %ecx,2), %edx 9 + x + 2y %edx = 9 + x + (2*y) = 9 + x + 2y. 4. Soal : [Practice Problem 3.4] Assume the following values are stored at the indicated memory addresses and registers : Address Value 0x100 0xFF 0x104 0xAB 0x108 0x13
  • 7. 0x10C 0x11 Address Value %eax 0x100 %ecx 0x1 %edx 0x3 Fill in the following table showing the effects of the following instructions, both in terms of the register or memory location that will be updated and the resulting value. Instruksi Tujuan Nilai add1 %ecx, (%eax) 0x100 sub1 %edx, 4 (%eax) Imu11 $16 (%eax, %edx, 4) Inc1 8 (%eax) dec1 %ecx sub1 %edx, %eax Jawab : Instruksi Tujuan Nilai add1 %ecx, (%eax) 0x100 0x100 sub1 %edx, 4 (%eax) 0x104 0xA8 Imu11 $16 (%eax, %edx, 4) 0x10C 0x110 Inc1 8 (%eax) 0x108 0x14 dec1 %ecx %ecx 0x0 sub1 %edx, %eax %eax 0xFD 5. Soal : [Problem 3.31] You are given the information that follows. A function with prototype void decode2(int x, int y, int z); is compiled into assembly code. The body of the code is as follows: 1.movl 16(%ebp), %eax 2.movl 12(%ebp), %edx 3.sub %eax, %edx; 4.movl %edx, %eax 5.imull 8(%ebp), %edx 6.sall $31, %eax 7.sarl $31, %eax 8.xorl %edx, %eax
  • 8. #C Code int decode2(int x, int y, int z) { int t1 = y - z; int t2 = x * t1; int t3 = (t1 << 31) >> 31; int t4 = t3 ˆ t2; return t4; } Parameters x, y, and z are stored at memory locations with offsets 8, 12, and 16 relative to the address in register %ebp. The code stores the return value in register %eax. Write C code for decode2 that will have an effect equivalent to the assembly code. You can test your answer by compiling your code with the –S switch. Your compiler may not generate identical code, but it should be functionally equivalent. Jawab : Membuat file jawabansoalno5.c putu-shinoda@my-machine:~$ touch jawabansoalno5.c Mengisikan script C ke dalam file jawabansoalno5.c putu-shinoda@my-machine:~$ nano jawabansoalno5.c Kode C yang dimasukkan int decode2(int x, int y, int z) { int t1 = y - z; int t2 = x * t1; int t3 = (t1 << 31) >> 31; int t4 = t3 ˆ t2; return t4; } Ditampilkan pada gambar berikut
  • 9. Kemudian dilanjutkan mencompile file jawabansoalno5.c dengan opsi -S putu-shinoda@my-machine:~$ gcc -O -S jawabansoalno5.c Terbentuk file jawabansoalno5.s dengan isi file sebagai berikut