assembly code转换成c代写-CS 354
时间:2021-04-06
CS 354
Machine Organization and
Programming
Week 8e
Michael Doescher
Spring 2021
Casting Review and Endianness
Bitwise Operations
Binary Arithmetic
File Input/Output
Introduction to Assembly
What happens when we run a program?
Compiling
sum.c
……
a = 1;
b = 2;
c = a + b;
……
Compiler
gcc
Sum
00101010
10101010
10101010
10000110
11100110
What happens when we run a program?
sum.c
……
a = 1;
b = 2;
c = a + b;
……
Processor Memory
Disk
sum.c
……
a = 1;
b = 2;
c = a + b;
……
sum
00101010
10101010
10101010
10000110
11100110
Code
c = a + b;
Stack
main
▪ a =1
▪ b =2
▪ c
Data
Heap
What does the CPU do?
fetch
decode
execute
sum.c
……
a = 1;
b = 2;
c = a + b;
……
What happens when we run a program?
sum.c
……
a = 1;
b = 2;
c = a + b;
……
Processor Memory
Disk
sum.c
……
a = 1;
b = 2;
c = a + b;
……
sum
00101010
10101010
10101010
10000110
11100110
Code
c = a + b;
Stack
main
▪ a =1
▪ b =2
▪ c
Data
Heap
%eax
%ebx
%ecx
%IP
What happens when we run a program?
sum.c
……
a = 1;
b = 2;
c = a + b;
……
Processor Memory
Disk
sum.c
……
a = 1;
b = 2;
c = a + b;
……
sum
00101010
10101010
10101010
10000110
11100110
Code
c = a + b;
Stack
main
▪ a =1
▪ b =2
▪ c
Data
Heap
%eax
%ebx
%ecx
%IP
mov 0x100, %eax
mov 0x104, %ebx
add %eax, %ebx
mov %ebx, 0x108
Build Process
Preprocessor (CPP)
Compiler Proper (CC1)
Assembler (AS)
Linker (LD)
sum.c
……
a = 1;
b = 2;
c = a + b;
……
sum.i (preprocessed source file)
Source
file
sum.s (assembly file)
sum.0 (relocatable object file)
sum
00101010
10101010
10101010
10000110
11100110
sum
(executable)
Assembly
Intel X86 ARM SPARC
Assembly
Intel X86
8086
80186
80286
Pentium
X86
ARM SPARC
Assembly
Intel X86
8086
80186
80286
Pentium
X86
ARM SPARC
AT&T
Unix
Intel
MS-Dos - Windows
Assembly
Intel X86
8086
80186
80286
Pentium
X86
ARM SPARC
AT&T
Unix
add source, destination
Intel
MS-Dos – Windows
add destination, source
Registers
Registers
1. Data Transfer
2. Arithmetic Operators (add, sub, mult, div)
3. Memory
4. Bitwise Operations at the assembly level

























































































































































































































































































































































































































学霸联盟


essay、essay代写
essay、essay代写