forked from nahin100/17-CSE4102
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
4,254 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include<stdio.h> | ||
|
||
int main() | ||
{ | ||
int a, b, c; | ||
b = 10; | ||
c = 20; | ||
a = b + c; | ||
printf("a = %d\n", a); | ||
//gcc -o HelloWorld HelloWorld.c | ||
//gcc -E HelloWorld.c > HelloWorld.i | ||
//gcc -S -masm=intel HelloWorld.i | ||
//as -o HelloWorld.o HelloWorld.s | ||
//objdump -M intel -d HelloWorld.o > HelloWorld.dump | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
HelloWorld.o: file format pe-i386 | ||
|
||
|
||
Disassembly of section .text: | ||
|
||
00000000 <_main>: | ||
0: 55 push ebp | ||
1: 89 e5 mov ebp,esp | ||
3: 83 e4 f0 and esp,0xfffffff0 | ||
6: 83 ec 20 sub esp,0x20 | ||
9: e8 00 00 00 00 call e <_main+0xe> | ||
e: c7 44 24 1c 0a 00 00 mov DWORD PTR [esp+0x1c],0xa | ||
15: 00 | ||
16: c7 44 24 18 14 00 00 mov DWORD PTR [esp+0x18],0x14 | ||
1d: 00 | ||
1e: 8b 54 24 1c mov edx,DWORD PTR [esp+0x1c] | ||
22: 8b 44 24 18 mov eax,DWORD PTR [esp+0x18] | ||
26: 01 d0 add eax,edx | ||
28: 89 44 24 14 mov DWORD PTR [esp+0x14],eax | ||
2c: 8b 44 24 14 mov eax,DWORD PTR [esp+0x14] | ||
30: 89 44 24 04 mov DWORD PTR [esp+0x4],eax | ||
34: c7 04 24 00 00 00 00 mov DWORD PTR [esp],0x0 | ||
3b: e8 00 00 00 00 call 40 <_main+0x40> | ||
40: b8 00 00 00 00 mov eax,0x0 | ||
45: c9 leave | ||
46: c3 ret | ||
47: 90 nop |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
.file "HelloWorld.c" | ||
.intel_syntax noprefix | ||
.def ___main; .scl 2; .type 32; .endef | ||
.section .rdata,"dr" | ||
LC0: | ||
.ascii "a = %d\12\0" | ||
.text | ||
.globl _main | ||
.def _main; .scl 2; .type 32; .endef | ||
_main: | ||
LFB10: | ||
.cfi_startproc | ||
push ebp | ||
.cfi_def_cfa_offset 8 | ||
.cfi_offset 5, -8 | ||
mov ebp, esp | ||
.cfi_def_cfa_register 5 | ||
and esp, -16 | ||
sub esp, 32 | ||
call ___main | ||
mov DWORD PTR [esp+28], 10 | ||
mov DWORD PTR [esp+24], 20 | ||
mov edx, DWORD PTR [esp+28] | ||
mov eax, DWORD PTR [esp+24] | ||
add eax, edx | ||
mov DWORD PTR [esp+20], eax | ||
mov eax, DWORD PTR [esp+20] | ||
mov DWORD PTR [esp+4], eax | ||
mov DWORD PTR [esp], OFFSET FLAT:LC0 | ||
call _printf | ||
mov eax, 0 | ||
leave | ||
.cfi_restore 5 | ||
.cfi_def_cfa 4, 4 | ||
ret | ||
.cfi_endproc | ||
LFE10: | ||
.ident "GCC: (MinGW.org GCC-6.3.0-1) 6.3.0" | ||
.def _printf; .scl 2; .type 32; .endef |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
CC = gcc | ||
CFLAGS = -I. | ||
DEPS = hellomake.h | ||
OBJS = hellomake.o hellofunc.o | ||
|
||
all: | ||
gcc -o HelloWorld HelloWorld.c | ||
gcc -E HelloWorld.c > HelloWorld.i | ||
gcc -S -masm=intel HelloWorld.i | ||
as -o HelloWorld.o HelloWorld.s | ||
objdump -M intel -d HelloWorld.o > HelloWorld.dump | ||
gcc -c -o HelloWorld.o HelloWorld.c | ||
objdump -M intel -d HelloWorld.o > HelloWorld2.dump | ||
|
||
hellomake: hellomake.c hellofunc.c | ||
gcc -o hellomake hellomake.c hellofunc.c -I. | ||
|
||
hellomake2: hellomake.o hellofunc.o | ||
$(CC) -o hellomake hellomake.o hellofunc.o $(CFLAGS) | ||
|
||
# hellomake.o: hellomake.c | ||
# gcc -c -o hellomake.o hellomake.c -I. | ||
|
||
# hellofunc.o: hellofunc.c | ||
# gcc -c -o hellofunc.o hellofunc.c -I. | ||
|
||
hellomake3: $(OBJS) | ||
$(CC) -o $@ $^ $(CFLAGS) | ||
|
||
%.o: %.c $(DEPS) | ||
gcc -c -o $@ $< -I. | ||
|
||
.PHONY: clean | ||
|
||
clean: | ||
rm -f *.o | ||
|
||
assembler: | ||
C:\masm32\bin\ml /c /coff /Cp prog1.asm | ||
C:\masm32\bin\link -entry:main /subsystem:console prog1.obj | ||
prog1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include<stdio.h> | ||
#include<hellomake.h> | ||
|
||
void myPrintHelloMake() | ||
{ | ||
printf("My Print Hello Make 23\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include<hellomake.h> | ||
|
||
int main() | ||
{ | ||
myPrintHelloMake(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
void myPrintHelloMake(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.686 | ||
.model flat, c | ||
include C:\masm32\include\msvcrt.inc | ||
includelib C:\masm32\lib\msvcrt.lib | ||
|
||
.stack 100h | ||
printf PROTO arg1:Ptr Byte | ||
|
||
.data | ||
msg byte "Hello World", 0Ah, 0 | ||
|
||
.code | ||
main proc | ||
INVOKE printf, ADDR msg | ||
ret | ||
main endp | ||
end |
Binary file not shown.