Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4020412
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:13:30+00:00 2026-05-20T10:13:30+00:00

I used to compile my asm code with TASM (on winXP) but I had

  • 0

I used to compile my asm code with TASM (on winXP) but I had some troubles so now I use NASM (on linux). This snippet shows what I’m trying to do:

(gdb) list 35
30      xor ecx,ecx             # ecx is a counter
31      mov bl, ' '             # this is what I'm looking for
32  count_spaces:
33      mov al,[esi]            # grab a char
34      jz  spaces_counted      # is this the end?
35      inc esi                 # next char
36      cmp al,bl               # found one?
37      jne count_spaces        # nope, loop
38      inc ecx                 # yep, inc counter
39      jmp count_spaces        # and loop

This looks correct to me, but:

Breakpoint 1, main () at project1.asm:30
30      xor ecx,ecx
(gdb) display (char) $al
1: (char) $al = 0 '\000'
(gdb) display (char) $bl
2: (char) $bl = 0 '\000'
(gdb) next
31      mov bl, ' '
2: (char) $bl = 0 '\000'
1: (char) $al = 0 '\000'
(gdb) 
count_spaces () at project1.asm:33
33      mov al,[esi]
2: (char) $bl = 0 '\000'
1: (char) $al = 0 '\000'
(gdb) 

I can’t understand why al and bl didn’t change.
I’m sure my code is correct, but.. I think I missed some NASM’s option?
BTW I compiled with

nasm -f elf -l project1.lst -o project1.o -i../include/ -g  project1.asm

After compiling, I disassembled the output and got:

 80483ec:   31 c9                   xor    %ecx,%ecx
 80483ee:   bb 20 00 00 00          mov    $0x20,%ebx

080483f3 <count_spaces>:
 80483f3:   8b 06                   mov    (%esi),%eax
 80483f5:   3d 00 00 00 00          cmp    $0x0,%eax
 80483fa:   74 0b                   je     8048407 <spaces_counted>
 80483fc:   46                      inc    %esi
 80483fd:   39 d8                   cmp    %ebx,%eax
 80483ff:   75 f2                   jne    80483f3 <count_spaces>
 8048401:   41                      inc    %ecx
 8048402:   e9 ec ff ff ff          jmp    80483f3 <count_spaces>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:13:31+00:00Added an answer on May 20, 2026 at 10:13 am

    Note that GDB doesn’t know about the 8 or 16 bit aliased registers. It will always print 0 for al, bl, ax, bx, etc. You should use eax, ebx, etc:

    (gdb) info registers bl
    Invalid register `bl'
    (gdb) info registers bx
    Invalid register `bx'
    (gdb) info registers ebx
    ebx            0xf7730ff4       -143454220
    (gdb) p $bl
    $1 = void
    (gdb) p $bx
    $2 = void
    (gdb) p $ebx
    $3 = -143454220
    (gdb) p/x $bl
    $4 = Value can't be converted to integer.
    (gdb) p/x $bx
    $5 = Value can't be converted to integer.
    (gdb) p/x $ebx
    $6 = 0xf7730ff4
    (gdb) p (char) $bl
    $7 = 0 '\0'
    (gdb) p (char) $bx
    $8 = 0 '\0'
    (gdb) p (char) $ebx
    $9 = -12 'ô'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Its a long time since I've used C but now I'm trying to compile
Recently, I am reading some Linux kernel space codes, I see this uint64_t used;
I have some code that used to compile with GWT 1.x and link into
I'm trying to detect the compiler used to compile my source code. I can
The following code used to compile with Delphi 2007: constructor TMyFile.Create(const _Filename: string); begin
It apparently used to compile with Borland's C++ Builder, but that was a long
Is there openly available headers which can be used to compile linux socket application
I used to compile for x64 using VS2008 express and win SDK. Recently rebuilt
What different methods can be used to compile Perl differently, in such a way
I need a compile time check for what version of glibc will be used.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.