Ajout des travaux effectuer
This commit is contained in:
93
23SCR/SCR016-ARM/SCR016.txt
Normal file
93
23SCR/SCR016-ARM/SCR016.txt
Normal file
@@ -0,0 +1,93 @@
|
||||
1 et 2. systeme d'exploitation : Linux en 64 bits / architect : aarch64 / process: Little Endian
|
||||
|
||||
2.
|
||||
|
||||
as -gstabs -o printHW.o printHW.s
|
||||
ld -O0 printHW.o
|
||||
|
||||
3.
|
||||
|
||||
./a.out => "Hello World!"
|
||||
|
||||
4]
|
||||
raban@rp73:~/SCR/TP16-ARM$ gdb a.out
|
||||
GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git
|
||||
Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
||||
This is free software: you are free to change and redistribute it.
|
||||
There is NO WARRANTY, to the extent permitted by law.
|
||||
Type "show copying" and "show warranty" for details.
|
||||
This GDB was configured as "aarch64-linux-gnu".
|
||||
Type "show configuration" for configuration details.
|
||||
For bug reporting instructions, please see:
|
||||
<https://www.gnu.org/software/gdb/bugs/>.
|
||||
Find the GDB manual and other documentation resources online at:
|
||||
<http://www.gnu.org/software/gdb/documentation/>.
|
||||
|
||||
For help, type "help".
|
||||
Type "apropos word" to search for commands related to "word"...
|
||||
Reading symbols from a.out...
|
||||
(gdb) run
|
||||
Starting program: /export/home/senart22/raban/SCR/TP16-ARM/a.out
|
||||
Hello World!
|
||||
[Inferior 1 (process 634476) exited normally]
|
||||
(gdb) l 10,15
|
||||
10 .text // tells assembler to assemble the following
|
||||
11 // in the text (code) section
|
||||
12 .globl _start // _start is there where the program starts,
|
||||
13 // .globl makes it visible to the linker
|
||||
14 _start:
|
||||
15 mov x0,#1 // value 1 is placed in register x0
|
||||
(gdb) b 12
|
||||
Breakpoint 1 at 0x4000b0: file printHW.s, line 15.
|
||||
(gdb) run
|
||||
Starting program: /export/home/senart22/raban/SCR/TP16-ARM/a.out
|
||||
|
||||
Breakpoint 1, _start () at printHW.s:15
|
||||
15 mov x0,#1 // value 1 is placed in register x0
|
||||
(gdb) i r x0 x1 x2 w8
|
||||
x0 0x0 0
|
||||
x1 0x0 0
|
||||
x2 0x0 0
|
||||
w8 0x0 0
|
||||
(gdb) step
|
||||
16 adr x1,msg // the address retained by label msg is placed in register x1
|
||||
(gdb) i r x0 x1 x2 w8
|
||||
x0 0x1 1
|
||||
x1 0x0 0
|
||||
x2 0x0 0
|
||||
w8 0x0 0
|
||||
(gdb) s
|
||||
17 mov x2,#13
|
||||
(gdb) i r x0 x1 x2 w8
|
||||
x0 0x1 1
|
||||
x1 0x4100d0 4260048
|
||||
x2 0x0 0
|
||||
w8 0x0 0
|
||||
(gdb) x /s 0x4100d0
|
||||
0x4100d0: "Hello World!\n"
|
||||
(gdb) x /14cb 0x4100d0
|
||||
0x4100d0: 72 'H' 101 'e' 108 'l' 108 'l' 111 'o' 32 ' ' 87 'W' 111 'o'
|
||||
0x4100d8: 114 'r' 108 'l' 100 'd' 33 '!' 10 '\n' 0 '\000'
|
||||
(gdb) s
|
||||
18 mov w8, #SYS_WRITE // svc must find the syscall number in w8
|
||||
(gdb) i r x0 x1 x2 w8
|
||||
x0 0x1 1
|
||||
x1 0x4100d0 4260048
|
||||
x2 0xd 13
|
||||
w8 0x0 0
|
||||
(gdb) s
|
||||
20 svc #0 // invoke syscall: displays on the screen
|
||||
(gdb) i r x0 x1 x2 w8
|
||||
x0 0x1 1
|
||||
x1 0x4100d0 4260048
|
||||
x2 0xd 13
|
||||
w8 0x40 64
|
||||
(gdb) s
|
||||
Hello World!
|
||||
21 mov x0, #0 // in x0 put the value you want to exit with
|
||||
(gdb) c
|
||||
Continuing.
|
||||
[Inferior 1 (process 634489) exited normally]
|
||||
(gdb)
|
||||
|
||||
BIN
23SCR/SCR016-ARM/a.out
Executable file
BIN
23SCR/SCR016-ARM/a.out
Executable file
Binary file not shown.
BIN
23SCR/SCR016-ARM/printHW.o
Normal file
BIN
23SCR/SCR016-ARM/printHW.o
Normal file
Binary file not shown.
24
23SCR/SCR016-ARM/printHW.s
Normal file
24
23SCR/SCR016-ARM/printHW.s
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
Lines enclosed here are comments
|
||||
A small program: prints "Hello World!"
|
||||
*/
|
||||
// From // to the end of this line is a comment: next are directives to the assembler
|
||||
.equ SYS_EXIT, 93
|
||||
.equ SYS_WRITE, 64
|
||||
.data // tells assembler to assemble the following in the data section
|
||||
msg: .asciz "Hello World!\n" //msg retains the address of the string
|
||||
.text // tells assembler to assemble the following
|
||||
// in the text (code) section
|
||||
.globl _start // _start is there where the program starts,
|
||||
// .globl makes it visible to the linker
|
||||
_start:
|
||||
mov x0,#1 // value 1 is placed in register x0
|
||||
adr x1,msg // the address retained by label msg is placed in register x1
|
||||
mov x2,#13
|
||||
mov w8, #SYS_WRITE // svc must find the syscall number in w8
|
||||
// and the syscall arguments in x0,x1,x2
|
||||
svc #0 // invoke syscall: displays on the screen
|
||||
mov x0, #0 // in x0 put the value you want to exit with
|
||||
mov w8,#SYS_EXIT
|
||||
svc #0
|
||||
.end
|
||||
6
23SCR/SCR016-ARM/small.c
Normal file
6
23SCR/SCR016-ARM/small.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#include<unistd.h>
|
||||
#include<stdlib.h>
|
||||
int main(void){
|
||||
write(1,"Hello World!\n",13);
|
||||
exit(0);
|
||||
}
|
||||
Reference in New Issue
Block a user