Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
latte
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zygzagZ
latte
Commits
50ebcb21
Commit
50ebcb21
authored
Dec 31, 2020
by
zygzagZ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minimal POC
parent
1069f66d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
0 deletions
+78
-0
Makefile
Makefile
+9
-0
hello32.s
hello32.s
+18
-0
hello64.s
hello64.s
+10
-0
libc.a
lib/libc.a
+0
-0
runtime.c
lib/runtime.c
+41
-0
No files found.
Makefile
View file @
50ebcb21
...
...
@@ -40,3 +40,12 @@ Info.o : src/Info.cpp src/Info.h src/InfoList.h src/Absyn.h
ParseError.o
:
src/ParseError.cpp src/Info.h src/InfoList.h src/Absyn.h src/ParseError.h
${
CC
}
${
CCFLAGS
}
-c
src/ParseError.cpp
lib/runtime.o
:
lib/runtime.c Makefile
gcc
-m32
-static
-L
/usr/lib/gcc-cross/i686-linux-gnu/8/
-c
lib/runtime.c
-o
lib/runtime.o
-fno-stack-protector
hello32.o
:
hello32.s Makefile
as
--32
hello32.s
-o
hello32.o
hello
:
hello32.o lib/runtime.o Makefile
ld
-m
elf_i386
-Llib
/
-e
main lib/runtime.o hello32.o
-lc
-o
hello
hello32.s
0 → 100644
View file @
50ebcb21
hello:
.string "Hello\n"
.globl main
.globl printStr
.globl printInt
.globl readInt
.globl readStr
.globl error
.globl exit
main:
pushl %ebp
movl %esp, %ebp
pushl $hello
call printStr
movl $0, %eax
pushl $0
call exit
hello64.s
0 → 100644
View file @
50ebcb21
hello: .string "Hello\n"
.globl main
main:
pushq %rbp
mov %rsp, %rbp
lea hello(%rip), %rdi
call puts
mov $0, %rax
leave
ret
lib/libc.a
0 → 100644
View file @
50ebcb21
File added
lib/runtime.c
0 → 100644
View file @
50ebcb21
// gcc -m32 -static -L/usr/lib/gcc-cross/i686-linux-gnu/8/ -c runtime.c -o runtime.o
// as --32 hello32.s -o hello32.o
// ld -m elf_i386 -L. -e main runtime.o hello32.o -lc
#include <stdio.h>
int
printInt
(
int
a
)
{
printf
(
"%d
\n
"
,
a
);
}
int
printStr
(
const
char
*
c
)
{
printf
(
"%s
\n
"
,
c
);
}
char
*
readStr
()
{
char
*
line
=
NULL
;
size_t
len
=
0
;
getline
(
&
line
,
&
len
,
stdin
);
return
line
;
}
int
readInt
()
{
char
minus
=
0
;
int
result
=
0
;
char
ch
;
ch
=
getchar
();
while
(
1
)
{
if
(
ch
==
'-'
)
break
;
if
(
ch
>=
'0'
&&
ch
<=
'9'
)
break
;
ch
=
getchar
();
}
if
(
ch
==
'-'
)
minus
=
1
;
else
result
=
ch
-
'0'
;
while
(
1
)
{
ch
=
getchar
();
if
(
ch
<
'0'
||
ch
>
'9'
)
break
;
result
=
result
*
10
+
(
ch
-
'0'
);
}
if
(
minus
)
return
-
result
;
else
return
result
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment