Repo init

This commit is contained in:
Jan Potocki
2020-06-22 17:31:00 +02:00
commit 5f9799c55c
11 changed files with 269 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
all: mul_arm
mul_arm: mul.s
gcc mul.s -o mul_arm
clean:
rm mul_arm
+103
View File
@@ -0,0 +1,103 @@
SYSEXIT = 1
SYSREAD = 3
SYSWRITE = 4
STDIN = 0
STDOUT = 1
num_length = 256
word_length = 4
buf_length = num_length * 2
num_words = num_length / word_length
buf_words = buf_length / word_length
.global main
.bss
num1: .space num_length
num2: .space num_length
result: .space buf_length
.text
main:
loop:
mov r7, #SYSREAD
mov r0, #STDIN
ldr r1, =num1
mov r2, #buf_length
swi 0x0
cmp r0, #buf_length
blt end
ldr r8, =num1
ldr r9, =num2
ldr r10, =result
eor r0, r0, r0
eor r4, r4, r4
zero:
str r0, [r10, r4, lsl#2]
add r4, r4, #1
cmp r4, #buf_words
blt zero
eor r4, r4, r4
loop1:
eor r11, r11, r11
eor r12, r12, r12
eor r2, r2, r2
eor r5, r5, r5
loop2:
ldr r0, [r8, r4, lsl#2]
ldr r3, [r9, r5, lsl#2]
umull r0, r1, r0, r3
msr apsr_nzcvq, r11
adcs r0, r0, r2
mrs r11, apsr
mov r2, r1
add r6, r4, r5
msr apsr_nzcvq, r12
ldr r1, [r10, r6, lsl#2]
adcs r1, r0, r1
str r1, [r10, r6, lsl#2]
mrs r12, apsr
add r5, r5, #1
cmp r5, #num_words
blt loop2
add r6, r6, #1
msr apsr_nzcvq, r11
adc r2, r2, #0
msr apsr_nzcvq, r12
ldr r1, [r10, r6, lsl#2]
adc r1, r1, r2
str r1, [r10, r6, lsl#2]
add r4, r4, #1
cmp r4, #num_words
blt loop1
mov r7, #SYSWRITE
mov r0, #STDOUT
ldr r1, =result
mov r2, #buf_length
swi 0x0
b loop
end:
mov r7, #SYSEXIT
mov r0, #0
swi 0x0
BIN
View File
Binary file not shown.