Author Topic: Marie Assembly  (Read 5795 times)

Offline maplesirop

  • Jr. Member
  • *
  • Posts: 60
Marie Assembly
« on: March 27, 2013, 03:38:57 AM »
I would like to know how ASCII characters are stored as inputs... Are they implicitly converted into decimal values? What if we write a number? Will the value be the number itself or the ASCII decimal value? For instance, I think 0 is 48 in ASCII, will the decimal value of the user's input be 0 or 48?

Offline Nicholas Westerhausen

  • Jr. Member
  • *
  • Posts: 9
Re: Marie Assembly
« Reply #1 on: March 28, 2013, 11:19:00 PM »
To my knowledge, the input is handled by the kernel, because you are making a kernel call to read from whatever. And it stores the ASCII value of the input as a series of bytes, in binary (usually read by us humans in HEX).

So user types in '0'. The sys_read returns (DEC 48), 0011 0000 BIN (0x30 HEX).

Offline TightCoderEx

  • Full Member
  • **
  • Posts: 103
Re: Marie Assembly
« Reply #2 on: March 29, 2013, 12:56:09 AM »
Under normal circumstances, yes "0" will be returned as 48 (30H).  The reason I say normal circumstances, is that any input driver can be hooked or replaced entirely and if your app is specifically oriented around digits only, then 48 - 57 (30H - 39H) could be returned as values 0 - 9 by the keyboard input driver.

You can find a myriad of conversion rountines, that will convert digits whether they come from keyboard or elsewhere to 8-16-32-64 bit signed or unsigned integers and even BCD and floating point values.

Even the keyboard does not pass 53 (35H) to the driver, rather 2E when the "5" key is pressed and F0 2E when it's released.  The driver recognizes this and converts it to 53.

Offline maplesirop

  • Jr. Member
  • *
  • Posts: 60
Re: Marie Assembly
« Reply #3 on: March 29, 2013, 10:41:58 PM »
So basically the values between 0 and 9 will be between 48 and 58 and all the non-digit char will be in the 59+ range?

If I want to print a digit I must pass a value between 48 and 58 to the AC?

I can use decimal values instead of HEX or binary, right (because the computer makes an implicit conversion)?