Author Topic: Slightly confused  (Read 4107 times)

Offline js19

  • Jr. Member
  • *
  • Posts: 4
Slightly confused
« on: March 01, 2016, 02:38:47 AM »
I'm working on a project and I have 2 tables of values like so...

letters: db  'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'

map:   db  007, 008, -1, -1, -1, 012, -1, -1, -1, -1, -1, -1, -1, 010, -1, -1, -1, 013, -1, 009, -1, 011, -1, -1, -1, -1

I'm trying to use ecx as counter to iterate through "letters" and once I find a certain letter, I find it in "map" . Why can't I do something like...

mov al, [map + ecx]  ; al should contain 007 or \a

so if the user enters an 'a', I find 'a' at 0 (ecx), then add 0 (ecx) to map to get 007 in al.
Thanks



Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2597
  • Country: us
Re: Slightly confused
« Reply #1 on: March 01, 2016, 03:31:55 AM »
I think you should be able to do exactly that. Tell us more about what's happening instead...

Best,
Frank


Offline js19

  • Jr. Member
  • *
  • Posts: 4
Re: Slightly confused
« Reply #2 on: March 01, 2016, 04:05:39 AM »
Thanks for the reply.

So the program is suppose to go
Enter String: string\nnew Line
Original: string\nnew Line
converted: string
newLine                  ; I get converted: stringnnew Line

 Is there a certain way to post code or can we copy and paste? Sorry, new to the site.   


Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2597
  • Country: us
Re: Slightly confused
« Reply #3 on: March 01, 2016, 04:48:16 AM »
You can copy and paste code. Put the word "code" in square brackets at the top of it and "/code" in square brackets at the end.

I'm getting more confused. From what I can see, your program removes the backslash from your string. Is that it? Nasm will recognize a backslash (\n, etc) if you enclose your string in "back apostrophes". I don't think it'll work with a "user-entered" string. I don't think I understand the problem yet. Be patient with me...

Best,
Frank


Offline js19

  • Jr. Member
  • *
  • Posts: 4
Re: Slightly confused
« Reply #4 on: March 01, 2016, 05:28:57 AM »
Hey Frank, thanks for taking the time to reply. I was using an online assembly compiler to run and test that code. Anyways, that method works on Linux and not the online compiler. Sorry for wasting your time since apparently this was an easy fix. 

But yeah NASM won't recognize the escape character from a user entered string, that's why I have to compare the character after the "\"  to the map table to get the escape character in hex.

Thanks again.