Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
nahin100 authored Sep 10, 2022
1 parent 9bb1fd7 commit c236eb7
Show file tree
Hide file tree
Showing 11 changed files with 4,254 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Lab 1/HelloWorld.c
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
}
28 changes: 28 additions & 0 deletions Lab 1/HelloWorld.dump
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
456 changes: 456 additions & 0 deletions Lab 1/HelloWorld.i

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions Lab 1/HelloWorld.s
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
3,643 changes: 3,643 additions & 0 deletions Lab 1/HelloWorld2.dump

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions Lab 1/Makefile
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
7 changes: 7 additions & 0 deletions Lab 1/hellofunc.c
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");
}
7 changes: 7 additions & 0 deletions Lab 1/hellomake.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include<hellomake.h>

int main()
{
myPrintHelloMake();
return 0;
}
1 change: 1 addition & 0 deletions Lab 1/hellomake.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void myPrintHelloMake();
17 changes: 17 additions & 0 deletions Lab 1/prog1.asm
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 added Lab 1/prog1.obj
Binary file not shown.

0 comments on commit c236eb7

Please sign in to comment.