Issue
I am using the ARMv8 instruction set with Aarch64 execution state. The problem I am having, is were supposed to translate C code into assembly, and I am stuck on the following:
while (c != '\n' && c != EOF)
c = getchar();
I know the basic setup for the while loop, as well as how to test c != '\n'
but the issue I have is how to write EOF
in assembly.
Can i just type
cmp c_r, EOF
b.eq skipwhile
or is it something else?
Solution
It depends on what code you're using in assembly for getchar()
-
- If you're just using a call to the assembly version of standard C library
getchar()
, then you can test with the C library's definition ofEOF
- normally-1
. - If you're implementing your own
getchar()
in assembly, then you need to match your test to the return value of yourgetchar()
implementation when it gets to the end-of-file.
Answered By - iVoid Answer Checked By - Marie Seifert (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.