Message from @DanielKO

Discord ID: 429761488996139008


2018-03-31 21:34:00 UTC  

That's what I do when debugging homebrew on my 3DS.

2018-03-31 21:34:15 UTC  

I'm gonna try with gdb -tui

2018-03-31 21:35:59 UTC  

It's one of the most basic things you want when coding asm, being able to see exactly what's on the stack, what the registers contain, see each instruction executing.

2018-03-31 21:36:43 UTC  

Another tool to use, **valgrind**.

2018-03-31 21:37:14 UTC  

Since you're writing asm, you could just as easily be corrupting all the memory and not realize it until way after.

2018-03-31 21:40:01 UTC  

Thanks, will look into this stuff

2018-03-31 21:40:35 UTC  

Also, gave me a bit of a heart attack when you said corrupting memory and so immediately backed up the previous two programs I wrote last night for this class.

2018-03-31 21:40:51 UTC  

Valgrind is a VM that does memory checking, it can call gdb to debug a program that appears to be misbehaving.

2018-03-31 21:41:31 UTC  

Corrupting RAM; I imagine you're storing the code in a more permanent storage, no?

2018-03-31 21:41:43 UTC  

yeah, just gave me a freak out for a second

2018-03-31 21:41:50 UTC  

Is that code running in kernel mode? Or user mode?

2018-03-31 21:42:27 UTC  

I'm assuming user mode

2018-03-31 21:53:12 UTC  

Well either you're running it as a regular application under an already running OS, or you're chainloading it via grub during boot.

2018-03-31 21:53:55 UTC  

Okay, definitely the first one.

2018-03-31 21:56:02 UTC  

So what are you trying to accomplish? Reading a string and adding its bytes together?

2018-03-31 21:56:58 UTC  

read in five numbers, sum them, print result.

2018-03-31 21:58:20 UTC  

You're using `scanf` with `"%s"` though.

2018-03-31 21:58:25 UTC  

oh shit

2018-03-31 21:58:29 UTC  

I forgot to change that

2018-03-31 21:58:38 UTC  

lol

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}

```