I'm working on a simple tutorial for iterating over a string with readable and changeable code. This is apart of a simple operating system project that is in the works. I'm documenting all the confusions I have while learning assembly and then presenting them in an understandable way but in the most simple. The code I wrote in its current form displays one character, the finished form will go through the string until it hits the null terminator. I'm wondering why when i doing the following works.
mov rsi, message + 2 ;print specific character
however when i do
mov rsi, message + rbp ;print specific character
I get an error: invalid operand type. I have searched stackoverflow(and other search engines) and have done random attempts to find the the offset operator to achieve the result of the first working code. I thought it was a plus operator, or maybe the colon(:) or perhaps the brackets([]), not sure how to indicate offset here.
Here is the working code version, how do i turn it into the "dynamic" version of picking the specific character to print?
global _start
section .data
message: db 'hello world!', 10
section .text
_start:
mov rbp, 1 ;tracks position of character to print
mov rax, 1 ;system call number for "write"
mov rdi, 1 ;first argument, where to write (terminal)
mov rsi, message + 2 ;second argument, print specific character
mov rdx, 1 ;third argument, bytes to write
syscall ;envoke process for the parameters/virtually placed lines
mov rax, 60
syscall
I have an alternative version that gets the full string length and then the syscall uses the string length to print out the entire string, however in this version i eventually want to demonstrate string transformations, splitting, and comparisons.