开发者

Reading floats from a file in ASM

开发者 https://www.devze.com 2023-02-04 05:09 出处:网络
I\'ve been working through the c++ and asm problems from The Binary Auditor.I got through the c++ stuff no problem, but the assembly is giving me a bit of trouble.I\'m using masm32开发者_StackOverflow

I've been working through the c++ and asm problems from The Binary Auditor. I got through the c++ stuff no problem, but the assembly is giving me a bit of trouble. I'm using masm32开发者_StackOverflow中文版 on Windows 7.

The first assembly problem essentially asks you to calculate the average of a series of float values which are stored in a text file, one value per line. So far, I've been able to read in the data from the file and store it in an array as a series of characters.

So, my question is, to extract the float values from the array will I need to physically look at each byte, detect newline characters and '.'s and then construct the floats? Is there an easier way?!

Thanks


Do it as you said. I think it can be done in a single pass: Read byte after byte from your file and construct the float immediately digit after digit.

If you are allowed to use CRT library, you can also call fscanf() or something to convert string to double, but I think the goal here is to do it in assembler, so do it as was said.

0

精彩评论

暂无评论...
验证码 换一张
取 消