Message from @meratrix
Discord ID: 430508897472872470
Try harder
git gud
I do have a textbook, but it doesn't go over specifics, just the general instruction set, and it's mostly computer architecture, there's one chapter on assembly
It seems to be summing the addresses instead of the values themselves
working on fixing that at the moment
Make sure you're loading the proper thing.
I believe I am, but I must be going wrong somewhere as my output is always the same thing, 676195
@meratrix have you tried going through line by line?
yeah, I've looking at the registers using gdb, it's really simple, a single line in the sum_loop
```
.data
print: .asciz "%d\n"
scan: .asciz "%d"
array: .skip 20
a: .word
.text
.global main
main:
push {fp, lr}
mov r6, #0 /* r6 <- 0 (sum) */
mov r7, #0 /* r7 <- 0 (loop counter) */
ldr r4, =array /* r4 <- &array */
in_loop:
cmp r7, #4 /* compare r3 and 4 */
bgt in_loop_end /* branch to in_loop_end if r3 >= 4 */
ldr r0, =scan /* r0 <- &scan */
ldr r1, =a /* r1 <- &a */
bl scanf /* calls scanf */
ldr r8, =a /* r8 <- &a */
str r8, [r4] /* store value of r8 into address of r4 */
add r4, r4, #4 /* r4 <- r4 + 4 */
add r7, r7, #1 /* r7 <- r7 + 1 */
b in_loop /* branch to in_loop */
in_loop_end:
mov r7, #0 /* r7 <- 0 (loop counter) */
/*ldr r4, =array*/ /* r4 <- &array */
sum_loop:
cmp r7, #4 /* compare r7 and 4 */
bgt sum_loop_end /* branch to sum_loop_end if r3 >= 4 */
lsl r5, r7, #2 /* get array offset */
ldr r9, [r4] /* r9 <- value at address r4 */
add r6, r6, r9 /* add onto sum in r6 with r5 as array[i] */
add r4, r4, #4 /* r4 <- r4 + 4 */
add r7, r7, #1 /* r7 <- r7 + 1 */
b sum_loop /* branch to sum_loop */
sum_loop_end:
mov r1, r6 /* r1 <- r6 */
ldr r0, =print /* r1 <- print */
bl printf /* calls printf */
pop {fp, pc}
```
Are you using the GNU assembler?
I am using gcc.
I actually just got a little closer, now it prints out the final number entered
hmmm,... it seems to be only storing the last number, everything else gets stored as 0
Are you using raspbian?
Try `apt-get install ddd`.
anybody who says JS is bad is a meanie
now watch as I spend 2 hours finding why some value is undefined
currently trying to figure out some issue where I am getting an object converted to JSON when I push it to an array
weird af
I'll admit javascript being loosely-typed is the dumbest thing on the planet, but it is still really helpful
I don't understand anyone who doesn't use semicolons
absolute madmen
MAD LAD
It's not the looseness, it's the unpredictable type rules.
I fucking got it mother fuckers
```
.data
print: .asciz "%d\n"
scan: .asciz "%d"
array: .skip 20
a: .word
.text
.global main
main:
push {fp, lr}
mov r6, #0 /* r6 <- 0 (sum) */
mov r7, #0 /* r7 <- 0 (loop counter) */
ldr r4, =array /* r4 <- &array */
in_loop:
cmp r7, #4 /* compare r7 and 4 */
bgt in_loop_end /* branch to in_loop_end if r3 >= 4 */
ldr r0, =scan /* r0 <- &scan */
ldr r1, =a /* r1 <- &a */
bl scanf /* calls scanf */
ldr r1, =a /* r1 <- &a */
ldr r9, [r1] /* r9 <- value at address r1 */
str r9, [r4] /* store value of r9 into address of r4 */
add r4, r4, #4 /* r4 <- r4 + 4 */
add r7, r7, #1 /* r7 <- r7 + 1 */
b in_loop /* branch to in_loop */
in_loop_end:
mov r7, #0 /* r7 <- 0 (loop counter) */
ldr r4, =array /* r4 <- &array */
sum_loop:
cmp r7, #4 /* compare r7 and 4 */
bgt sum_loop_end /* branch to sum_loop_end if r3 >= 4 */
ldr r5, [r4] /* r5 <- value at address r4 */
add r6, r6, r5 /* add onto sum in r6 with r5 as array[i] */
add r4, r4, #4 /* r4 <- r4 + 4 */
add r7, r7, #1 /* r7 <- r7 + 1 */
b sum_loop /* branch to sum_loop */
sum_loop_end:
mov r1, r6 /* r1 <- r6 */
ldr r0, =print /* r1 <- print */
bl printf /* calls printf */
pop {fp, pc}
```
AAAAH
assembly
what is the code for>
to be fair you have to have a very high IQ to understand ARM Assembly
read in 5 numbers from scanf and sum them
and... why?
😄
class
I have been trying to deal with assembly for a while
reverse engineering AAA games is no easy task