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 8693557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:34:16+00:00 2026-06-13T00:34:16+00:00

I have decided to learn assembler for fun. I have been coding in C

  • 0

I have decided to learn assembler for fun. I have been coding in C for many years.

I followed some online tutorials that print “Hello world” and dug around a bit in the NASM manual. All well and good. So, I set myself a task of printing “hello world” in a loop. I know I can do this with the loop opcode, but wanted to code it explicitly and use variables defined in the .bss section.

However, I obviously misunderstand how variable assignment works in assembly as I get the error message:

nasm -felf -o hello.o hello.asm
hello.asm:16: error: invalid combination of opcode and operands
hello.asm:17: error: invalid combination of opcode and operands
hello.asm:28: error: invalid combination of opcode and operands

I have tried searching the web for info on variable assignment, including the NASM manual, but can’t seem to find the information I need. Can anyone assist? Here’s my (simple!) code:

; print "Hello world!" to the screen multiple times

section .data
    msg:    db  'Hello world!', 10
    msglen: equ $ - msg

section .bss
    iter:   resb    1

section .text
    global _start

_start:

    ; loop 10 times
    mov iter, 0     ; initalise loop counter
FL: cmp iter, 10    ; is iter == 10?
    jge LoopEnd

    ; write the message to STDOUT:
    mov eax,4       ; code for write syscall
    mov ebx,1       ; stdout fd
    mov ecx,msg     ; message to print...
    mov edx,msglen  ; ...and it's length
    int 80h         ; kernel interrupt

    ; increment loop iterator
    inc iter
    jp FL

LoopEnd:


    ; now exit, with return code 0:
    mov eax,1
    mov ebx,0
    int 80h
  • 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-06-13T00:34:17+00:00Added an answer on June 13, 2026 at 12:34 am

    To make a memory reference in nasm, you must surround the address with square brackets. Additionally, in each of the cases you’ve got here, you also need to specify a size, like so:

        mov byte [iter], 0     ; initalise loop counter
    FL: cmp byte [iter], 10    ; is iter == 10?
    
        inc byte [iter]
    

    In this case, though, it would probably make more sense to store iter in a register instead of in memory. You’re clobbering most of the obvious ones with your system calls, but esi or edi look available.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For reasons of self-improvement / broadening my horizons I have decided to learn some
I decided to learn Django Forms. For a while now, I have been using
I've decided to learn Python 3. For those that have gone before, what did
I have been working in Java since I started programming and decided to learn
I've decided to learn some assembly, however I haven't been able to figure out
After programming with C# and Java for many years I finally decided to learn
I have stubbornly decided to learn Xlib programming for Linux GUIs, just for fun
Greetings, everyone. I'm trying to learn some Silverlight basics, and have decided to write
I'm attempting to learn Scala so I have decided to implement datastructures with it.
I have decided to add some validation to my combobox, what I'm trying to

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.