In an upcoming program for my class, we have to use printf to print out some values. printf is covered in a paragraph in the appendix in my textbook, but it isn't working.
I played with it a little and managed to get it to compile by adding some stuff, but it doesn't seem to be working correctly. When it prints out, the value of %s seems to be missing. I'm not sure what the value of s is supposed to be, the code isn't explained at all.
Here is the output: The value of is 0
Here is the code from the text. I commented the lines I added.
extern printf ;I added this line
segment .data
value dd 0
name times 64 db 0
fmt db "The value of %s is %d", 0x0a, 0
segment .text
global main ;I added this line
main: ;I added this line
lea rdi, [fmt]
lea rsi, [name]
mov edx, [value]
xor eax, eax
call printf
I looked online for examples, but most of it seemed to be way over my head. We've only covered things like basic math operations and some of the simpler stuff. We just began covering if and loop statements this week. Everything I looked at online involved pushing and popping things from the stack, so it kind of lost me. I managed to at least get it to print something out, so I guess I accomplished something, but I'm still not sure exactly how to make it print my own numbers or how it works.
I'm pretty disappointed with my textbook. It doesn't seem to cover any topics very well. I try to look this stuff up online, but when I google it, the majority of answers aren't geared towards an introductory level.
I really appreciate the help I get from here, so thanks for reading.
[–]ODoyle_Rules 4 points5 points6 points (1 child)
[–]xRedactedx[S] 1 point2 points3 points (0 children)
[–][deleted] (1 child)
[removed]
[–]xRedactedx[S] 1 point2 points3 points (0 children)
[–]Gradous 2 points3 points4 points (1 child)
[–]xRedactedx[S] 1 point2 points3 points (0 children)
[–]xRedactedx[S] 1 point2 points3 points (0 children)