This commit is contained in:
2023-12-10 15:48:26 +01:00
parent cdbec2b91f
commit 7a18fddeb4
44 changed files with 1977 additions and 10 deletions

BIN
arm/.small-loop.s.swp Normal file

Binary file not shown.

15
arm/add-int.s Normal file
View File

@@ -0,0 +1,15 @@
.equ SYS_EXIT, 93
.data
int1 : .quad 0x15
int2 : .quad 0x2
.text
.global _start
_start: adr x3, int1
ldr x0, [x3]
adr x3, int2
ldr x1, [x3]
add x2,x0,x1
mov x0, #0
mov w8, #SYS_EXIT
svc #0

16
arm/adds-int32.s Normal file
View File

@@ -0,0 +1,16 @@
.equ SYS_EXIT, 93
.data
int1 : .word 0x7fffffff
int2 : .word 0x1
.text
.global _start
_start: adr x3, int1
ldr w0, [x3]
adr x3, int2
ldr w1, [x3]
adds w2,w0,w1
mrs x4, nzcv
mov w0, #0
mov w8, #SYS_EXIT
svc #0

14
arm/barrel-experiment.s Normal file
View File

@@ -0,0 +1,14 @@
.equ SYS_EXIT, 93
.data
.text
.globl _start
_start :
mov x0, #15
add x1,x0,x0,lsl #4 //x0 * 16 + x0
mov x2, #1
sub x1,xzr,x2, lsl #3 // 0 - 8
mov w8, #SYS_EXIT
svc #0

16
arm/mult-bin-loop.c Normal file
View File

@@ -0,0 +1,16 @@
#include <stdio.h>
#include <stdlib.h>
int main(){
unsigned int a = 0xa2;
unsigned int b = 0xb;
unsigned long long int res = 0;
unsigned long long int extra = (unsigned long long int) a;
while (b) {
if (b & 0x1) res += extra;
extra = extra << 1;
b = b >> 1;
}
exit(0);
}

28
arm/mult-bin-loop.s Normal file
View File

@@ -0,0 +1,28 @@
.equ SYS_EXIT,93
.data
int1: .word 0xa2
int2: .word 0xb
.text
.globl _start
_start:
adr x1, int1
ldr w0, [x1]
uxtw x1, w0 // int1 is in x1
adr x2, int2
ldr w3, [x2]
uxtw x2, w3 // int2 is in x2
mov x0, #0 // result is in x0
loop:
cbz x2, exit
tbz x2, #0, next
add x0, x2, #0
next:
lsl x2, x2, #1
lsr x1, x1, #1
b loop
exit: mov x0,#0
mov w8,#SYS_EXIT
svc #0x0
.end

3
arm/notes.txt Normal file
View File

@@ -0,0 +1,3 @@
cmp = subs sans sauvegarde résultat
0111 + 0001
tst =

24
arm/printHW.s Normal file
View 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

18
arm/shift-experiment.s Normal file
View File

@@ -0,0 +1,18 @@
.equ SYS_EXIT, 93
.data
.text
int: .quad 0x8000000000000000
.globl _start
_start :
mov x0, #1
lsl x1, x0, #3
lsr x2, x0, #1
adr x6, int
ldr x3,[x6]
lsr x4, x3, #3
asr x5, x3, #3
mov w8, #SYS_EXIT
svc #0

View File

@@ -0,0 +1,16 @@
.equ SYS_EXIT, 93
.data
int: .quad 0x11223344aabbccdd
int32: .word 0x887766ee
.text
.globl _start
_start:
adr x1, int
ldr x0,[x1]
adr x1, int32
ldr w0,[x1] //Le registre x0 est vidé pour ne contenir seulement la valeur int32
sxtw x0, w0
mov x0, #0
mov w8, #SYS_EXIT
svc #0