PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, October 30, 2022

[FIXED] How to type EOF in ARMv8 Assembly?

 October 30, 2022     armv8, assembly, c, eof     No comments   

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 of EOF - normally -1.
  • If you're implementing your own getchar() in assembly, then you need to match your test to the return value of your getchar() implementation when it gets to the end-of-file.


Answered By - iVoid
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing