0

Hi,

i am using emu8068 and i want to know how i read from a file or buffer(with file text) a specified caractes.

I have a file named "config.txt" and it seems like that:

Easy 50 10
Hard 20 5

When user select Easy/Hard i want to catch the 50 to a variable and 10 to other. First i need to compare the level, but my problem is how i catch this numbers.

Thank for any idea :)

2
Contributors
1
Reply
8
Views
3 Years
Discussion Span
Last Post by turboscrew
0

I think you can't read numbers, but just characters.
You just have to "build" the numbers from the digits yourself.

If you think of it, the ascii codes of numbers are 0x30 - 0x39, so you get the value of the digit by subtracting the ascii code of '0' (=0x30) from the character.

in a sort of pseudocode

xor bx,bx ; result = 0
loop:
  read ax ; get digit
  cmpi ax 0x30 ; less than '0'
  jlt done
  cmpi ax 0x39 ; greater than '9'
  jgt done

  mul bx, 10 ; result = result * 10
  subi ax, 0x30
  add bx, ax ; result = result +m new digit
  jmp loop

done:
  ; return bx
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.