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 :)

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.