9 Replies - 215 Views - Last Post: 24 September 2018 - 06:37 AM Rate Topic: -----

#1 LauriKiwi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 24-September 18

How to convert hex from keyboard to ASCII for string

Posted 24 September 2018 - 06:15 AM

Hello. I would like to know a simple solution to converting hex code from the keyboard to ASCII for a string.
If you have a solution, please explain it because I'm a noob.
I am working in independent x86 assembly.
Is This A Good Question/Topic? 0
  • +

Replies To: How to convert hex from keyboard to ASCII for string

#2 Programmer2004   User is offline

  • D.I.C Head

Reputation: 18
  • View blog
  • Posts: 96
  • Joined: 25-October 17

Re: How to convert hex from keyboard to ASCII for string

Posted 24 September 2018 - 06:20 AM

Do you want to convert that ASCII code to string representation like "0x4F" or to convert it to a character?
Was This Post Helpful? 1
  • +
  • -

#3 LauriKiwi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 24-September 18

Re: How to convert hex from keyboard to ASCII for string

Posted 24 September 2018 - 06:21 AM

Character, I guess.
Was This Post Helpful? 0
  • +
  • -

#4 Programmer2004   User is offline

  • D.I.C Head

Reputation: 18
  • View blog
  • Posts: 96
  • Joined: 25-October 17

Re: How to convert hex from keyboard to ASCII for string

Posted 24 September 2018 - 06:25 AM

Ok, now I understand, you want to add pressed character to string. To do that, you just insert the ASCII code in the string at the position where it should be. String is just an array of ASCII codes, and ASCII code is 1 byte, so every character in that string is 1 byte.
Was This Post Helpful? 1
  • +
  • -

#5 LauriKiwi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 24-September 18

Re: How to convert hex from keyboard to ASCII for string

Posted 24 September 2018 - 06:26 AM

Can you provide an example for that?
Was This Post Helpful? 0
  • +
  • -

#6 Programmer2004   User is offline

  • D.I.C Head

Reputation: 18
  • View blog
  • Posts: 96
  • Joined: 25-October 17

Re: How to convert hex from keyboard to ASCII for string

Posted 24 September 2018 - 06:28 AM

Sure, no problem, but first I need to know for what platform do you write your code?
Was This Post Helpful? 0
  • +
  • -

#7 LauriKiwi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 24-September 18

Re: How to convert hex from keyboard to ASCII for string

Posted 24 September 2018 - 06:31 AM

x86 assembly. Boots directly from BIOS.

Linux I forgot to add linux xD

Well that's what I'm coding on.

The code itself boots from BIOS or in this case QEMU.
Was This Post Helpful? 0
  • +
  • -

#8 Programmer2004   User is offline

  • D.I.C Head

Reputation: 18
  • View blog
  • Posts: 96
  • Joined: 25-October 17

Re: How to convert hex from keyboard to ASCII for string

Posted 24 September 2018 - 06:35 AM

Ok, so the platform is just an x86 PC without any operating system.

Alright, here's the example:

mov bx, 0 ;The BX register will be used for addressing

.stringLoop:
   ;Read character
   mov ah,0
   int 0x16
   
   ;Save returned character to someString at offset BX
   mov byte [someString + bx], al

   ;Increase BX to write next character at next position and repeat the loop
   inc bx
   jmp .stringLoop

someString db 0 ;This is the string variable



This is the shortest example I can think of. You can also add compare instructions which would end the loop when user presses the Enter key, etc., etc.
Was This Post Helpful? 1
  • +
  • -

#9 LauriKiwi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 24-September 18

Re: How to convert hex from keyboard to ASCII for string

Posted 24 September 2018 - 06:36 AM

Okay thanks!
Was This Post Helpful? 0
  • +
  • -

#10 Programmer2004   User is offline

  • D.I.C Head

Reputation: 18
  • View blog
  • Posts: 96
  • Joined: 25-October 17

Re: How to convert hex from keyboard to ASCII for string

Posted 24 September 2018 - 06:37 AM

You're welcome.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1