Moving a Statement into Local Variable
- ClarionCoder51
- Member
- Posts: 28
- Joined: Sun Aug 16, 2009 11:52 am
- Location: Georgia, USA
Moving a Statement into Local Variable
I am attempting to put the prompt letter into a local variable. The only problem is, I need to know HOW to DEFINE a variable and HOW to move a text value, like 'A>', into it using it in a mov statement. Every single possible combination of syntax and code that I could come up with doesn't work, so I'm hoping someone will atleast throw out an innertube so I won't drown in code in my sleep.
"The n00b zone is for loading and unloading newbies only."
- Troy Martin
- Member
- Posts: 1686
- Joined: Fri Apr 18, 2008 4:40 pm
- Location: Langley, Vancouver, BC, Canada
- Contact:
Re: Moving a Statement into Local Variable
EDIT: reading over your previous topic, I've shaved some stuff off.
Write a callable function called, say, strcpy, that copies a null-terminated string byte-by-byte from a string pointed to by SI to an array of bytes (another string, hehe) in DI. Voila.
You can't move/copy strings with the MOV instruction.
Write a callable function called, say, strcpy, that copies a null-terminated string byte-by-byte from a string pointed to by SI to an array of bytes (another string, hehe) in DI. Voila.
You can't move/copy strings with the MOV instruction.
Re: Moving a Statement into Local Variable
You can use "movsX", "cmpsX" assembly command for string operations.
Re: Moving a Statement into Local Variable
You don't need a string if the prompt is just one letter.
Maybe you'd better show us your code and tell us what assembler you are using (the above example is in NASM syntax).
Code: Select all
[section .data]
prompt_letter: db 0
[section .code]
mov byte [prompt_letter], 'A'
- ClarionCoder51
- Member
- Posts: 28
- Joined: Sun Aug 16, 2009 11:52 am
- Location: Georgia, USA
Re: Moving a Statement into Local Variable
Ok. In order to add '>' I would just call a separate string, like
...assuming that [prompt_letter] doesn't do a char return and puts '>' on the next line, which it shouldn't.
Code: Select all
[section .data]
prompt_letter: db 0
prompt_arrow: db '>'
[section .code]
mov byte [prompt_letter], 'A'
lea si, prompt_letter
call print_string ; <--- That functon prints the string to vid memory
lea si, prompt_arrow
call print_string
"The n00b zone is for loading and unloading newbies only."
Re: Moving a Statement into Local Variable
In NASM syntax, "lea si, prompt_arrow" should be "lea si, [prompt_arrow]" or a plain "mov si, prompt_arrow". And "print_string" should be printing a character, not a string.
Again, you'd better show us your code and tell us what assembler you are using.
Again, you'd better show us your code and tell us what assembler you are using.