Message from @Deleted User
Discord ID: 430114095233105925
Thanks, will look into this stuff
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.
Valgrind is a VM that does memory checking, it can call gdb to debug a program that appears to be misbehaving.
Corrupting RAM; I imagine you're storing the code in a more permanent storage, no?
yeah, just gave me a freak out for a second
Is that code running in kernel mode? Or user mode?
I'm assuming user mode
Well either you're running it as a regular application under an already running OS, or you're chainloading it via grub during boot.
Okay, definitely the first one.
So what are you trying to accomplish? Reading a string and adding its bytes together?
read in five numbers, sum them, print result.
You're using `scanf` with `"%s"` though.
oh shit
I forgot to change that
lol
That's why I said, write the C code first.
I was using my previous one as a template because that also had a loop, and that was for a string.
I mean, I still have a segfault, but that would have caused other problems obviously.
js should be left in a ditch
cause js is best bs
and never be talked about
JS == BS
Shitting on JS is the only way some JS programmers can cope with their job.
Keeps them from offing themselves.
<:think_hang:378717098903470080>
<:super_edgy:426099058466095119>
Then why do some JS coders spend so many time shitting on other lower level languages?
Cause everyone's got a salty side to them.
^
Because they don't know any better.
@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}
```
preferably with a bullet to the head,
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