Author Topic: Backquoted Strings  (Read 10461 times)

Offline Logman

  • Jr. Member
  • *
  • Posts: 16
  • Country: us
Backquoted Strings
« on: July 26, 2015, 05:54:33 PM »
I have run across an issue with the semi-colon when writing inline assembly procedures that call C Runtime Library functions.

Here is a code snippet to show my problem:

Code: [Select]
...high-level language code

%asm
extern _scanf, __imp__scanf                   ; Imported functions

section .data
  align 16
  scanset db "%16[a-z A-Z 0-9 -+=. ]", 0 ; Scanset to use with _scanf

section .bss
  align 16
  buffer resb 1024                                  ; Buffer to hold input from STDIN

section .text
  push dword buffer                               ; Push pointer to buffer
  push dword scanset                             ; Push pointer to scanset
  call [__imp__scanf]                             ; Call the C Runtime Library function
  add esp, 8                                          ; Balance the stack
%endasm

...remainder of high-level language code

The key here is that I can build a scanset of ASCII characters that will be recognized by the _scanf function. Characters not included in the scanset will be rejected/cutoff input.

I need to include the semi-colon in the scanset, but NASM considers the semi-colon the beginning of a comment. Therefore, I cannot include the semi-colon in the scanset. This is my dilemma. Would it be helpful if the semi-colon was included as a backquoted character in Section 3.4.2. There might be an obvious solution I'm overlooking.

Any insight into this problem would be much appreciated.

Logman
« Last Edit: July 26, 2015, 06:00:56 PM by Logman »