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

  • Home
  • SEARCH
  • 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 470091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:50:59+00:00 2026-05-12T23:50:59+00:00

So i was wondering if there is any? I know afd on windows but

  • 0

So i was wondering if there is any? I know afd on windows but not sure anything about mac?

And this his how i am using nasam on the following code: nasm a.asm -o a.com -l a.lst

[org 0x100]
mov ax, 5
mov bx, 10
add ax, bx
mov bx, 15
add ax, bx
mov ax, 0x4c00
int 0x21 

On windows i know a debugger name afd which help me to step through each statement but not sure how i can do this using gdb.

And neither i am able to execute this .com file, am i supposed to make some other file here?

  • 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-12T23:51:00+00:00Added an answer on May 12, 2026 at 11:51 pm

    Why are you writing 16-bit code that makes DOS syscalls? If you want to know how to write asm that’s applicable to your OS, take a look the code generated by “gcc -S” on some C code… (Note that code generated this way will have operands reversed, and is meant to be assembled with as instead of nasm)

    Further, are you aware what this code is doing? It reads to me like this:

    ax = 5
    bx = 10
    ax += bx
    bx = 15
    ax += bx
    ax = 0x4c00
    int 21h
    

    Seems like this code is equivalent to:

    mov bx, 15
    mov ax, 4c00
    int 21h
    

    Which according to what I see here, is exit(0). You didn’t need to change bx either…

    But. This doesn’t even apply to what you were trying to do, because Mac OS X is not MS-DOS, does not know about DOS APIs, cannot run .COM files, etc. I wasn’t even aware that it can run 16 bit code. You will want to look at nasm’s -f elf option, and you will want to use registers like eax rather than ax.

    I’ve not done assembly programming on OS X, but you could theoretically do something like this:

    extern exit
    global main
    main:
        push dword 0
        call exit
    
        ; This will never get called, but hey...
        add esp, 4
        xor eax, eax
        ret
    

    Then:

    nasm -f elf foo.asm -o foo.o
    ld -o foo foo.o -lc
    

    Of course this is relying on the C library, which you might not want to do. I’ve omitted the “full” version because I don’t know what the syscall interface looks like on Mac. On many platforms your entry point is the symbol _start and you do syscalls with int 80h or sysenter.

    As for debugging… I would also suggest GDB. You can advance by a single instruction with stepi, and the info registers command will dump register state. The disassemble command is also helpful.

    Update: Just remembered, I don’t think Mac OS X uses ELF… Well.. Much of what I wrote still applies. 🙂

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

Sidebar

Related Questions

I know it is not supported, but I am wondering if there are any
I know and have Xcode, but I was wondering if there were any other
I'm pretty sure I know the answer but I'm wondering if there's a way
i just wondering is there any performance issue or anything thing wrong if that
I was wondering if there were any real drawbacks associated with using LOGO? I
I am wondering if there is any drawback for using forward declarations in all
I'm wondering if there are any projects like Watin available for C++ (on Windows),
If this has already been asked, forgive me. But I'm wondering if there is
Just wondering if any know if there is any JavaScript API out there that
I am using the XmlSerializer, and was wondering if there is any way, using

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.