Message from @meratrix

Discord ID: 430259829840412672


2018-03-31 21:58:43 UTC  

That's why I said, write the C code first.

2018-03-31 21:59:17 UTC  

I was using my previous one as a template because that also had a loop, and that was for a string.

2018-03-31 21:59:37 UTC  

I mean, I still have a segfault, but that would have caused other problems obviously.

2018-04-01 04:31:48 UTC  

https://cdn.discordapp.com/attachments/423219052849397773/429860412595372033/1519943201705.jpg

2018-04-01 21:19:51 UTC  

@meratrix why more js

2018-04-01 21:19:59 UTC  

js should be left in a ditch

2018-04-01 21:20:04 UTC  

cause js is best bs

2018-04-01 21:20:04 UTC  

and never be talked about

2018-04-01 21:20:10 UTC  

JS == BS

2018-04-01 21:20:17 UTC  

Shitting on JS is the only way some JS programmers can cope with their job.

2018-04-01 21:20:29 UTC  

Keeps them from offing themselves.

2018-04-01 21:20:38 UTC  

<:think_hang:378717098903470080>

2018-04-01 21:20:49 UTC  

<:super_edgy:426099058466095119>

2018-04-01 23:40:44 UTC  

2018-04-01 23:40:56 UTC  

@meratrix 👌

2018-04-02 00:20:00 UTC  

Then why do some JS coders spend so many time shitting on other lower level languages?

2018-04-02 00:29:53 UTC  

Cause everyone's got a salty side to them.

2018-04-02 00:49:48 UTC  

^

2018-04-02 02:00:04 UTC  

Because they don't know any better.

2018-04-02 06:58:57 UTC  

@Deleted User Still doesn't work, ugh. Please end my misery.
```
.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 */
mov r3, #0 /* r3 <- 0 */
ldr r4, =array /* r4 <- array */

in_loop:
cmp r3, #5 /* compare r3 and 5 */
bge in_loop_end /* branch to in_loop_end if r3 >= 5 */
ldr r0, =scan /* r0 <- &scan */
ldr r1, =a /* r1 <- a */
bl scanf /* calls scanf */
ldr r1, =a /* r1 <- a */

add r4, r4, #1 /* r4 <- r4 + 1 */
add r3, r3, #1 /* r3 <- r3 + 1 */
b in_loop /* branch to in_loop */

in_loop_end:
mov r3, #0 /* r3 <- 0 */
ldr r4, =array /* r4 <- array */

sum_loop:
cmp r3, #5 /* compare r3 and 5 */
bge sum_loop_end /* branch to sum_loop_end if r3 >= 5 */
add r6, r6, r4 /* add onto sum in r6 with r4 as array[i] */
add r4, r4, #1 /* r4 <- r4 + 1 */
add r3, r3, #1 /* r2 <- r2 + 1 */
b sum_loop /* branch to sum_loop */

sum_loop_end:
mov r1, r6
ldr r0, =print /* r1 <- addr_print */
bl printf /* calls printf */

pop {fp, pc}

```

2018-04-02 06:59:18 UTC  

preferably with a bullet to the head,

2018-04-02 11:33:00 UTC  

@meratrix did they give you a book for this class?

2018-04-02 15:01:37 UTC  

Try harder

2018-04-02 15:02:45 UTC  

git gud

2018-04-02 20:46:41 UTC  

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

2018-04-02 20:47:13 UTC  

It seems to be summing the addresses instead of the values themselves

2018-04-02 20:47:19 UTC  

working on fixing that at the moment

2018-04-02 20:50:04 UTC  

Make sure you're loading the proper thing.

2018-04-02 20:50:52 UTC  

I believe I am, but I must be going wrong somewhere as my output is always the same thing, 676195

2018-04-02 20:59:59 UTC  

@meratrix have you tried going through line by line?

2018-04-02 21:08:01 UTC  

yeah, I've looking at the registers using gdb, it's really simple, a single line in the sum_loop

2018-04-02 21:09:27 UTC  

```
.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}


```

2018-04-02 21:09:28 UTC  

Are you using the GNU assembler?

2018-04-02 21:10:23 UTC  

I am using gcc.

2018-04-02 21:17:53 UTC  

I actually just got a little closer, now it prints out the final number entered

2018-04-02 21:18:58 UTC  

hmmm,... it seems to be only storing the last number, everything else gets stored as 0

2018-04-02 22:41:02 UTC  

Are you using raspbian?

2018-04-02 22:53:59 UTC  

Try `apt-get install ddd`.

2018-04-02 23:25:33 UTC  

anybody who says JS is bad is a meanie

2018-04-02 23:25:47 UTC  

now watch as I spend 2 hours finding why some value is undefined