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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:41:20+00:00 2026-05-24T21:41:20+00:00

I’m one day into learning ASM and I’ve done a few tutorials, and even

  • 0

I’m one day into learning ASM and I’ve done a few tutorials, and even successfully modified the tutorial content to use jmp and cmp, etc instead of the MASM .if and .while macros.

I’ve decided to try and write something very, very simple to begin with before I continue with more advanced tutorials. I’m writing a Fibonacci number generator. Here is the source I have so far:

.386
.model flat, stdcall

option casemap :none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib

.code
start:

  mov eax, 1
  mov ecx, 1

  _a:

    push eax
    add  eax, ecx
    pop  ecx

    ; Jump to _b if there is an overflow on eax

    ; Print Values Here

  jmp _a

  _b:

  push 0
  call ExitProcess

end start

I intend to check for overflows on eax/ecx but right now I’m just interested in displaying the values of eax/ecx on the screen.

I know how to push the address of a constant string from .data and call StdOut which was the first example in the hello world tutorial, but this appears to be quite different (?).

  • 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-24T21:41:21+00:00Added an answer on May 24, 2026 at 9:41 pm

    There is this code provided by Microsoft itself

    http://support.microsoft.com/kb/85068

    Note that this code outputs AX register on 16 bit systems. But you can get the idea, you just need to convert AX value into ASCII characters by looping through each character. Skip the interrupts part and use your StdOut function.

     mov dx, 4          ; Loop will print out 4 hex characters.
    nexthex:
              push dx            ; Save the loop counter.
              mov cl, 4          ; Rotate register 4 bits.
              rol ax, cl
              push ax            ; Save current value in AX.
    
              and al, 0Fh        ; Mask off all but 4 lowest bits.
              cmp al, 10         ; Check to see if digit is 0-9.
              jl decimal         ; Digit is 0-9.
              add al, 7          ; Add 7 for Digits A-F.
    decimal:
              add al, 30h        ; Add 30h to get ASCII character.
    
              mov dl, al
              ;Use StdOut to print value of dl
               ;mov ah, 02h        ; Prepare for interrupt.
              ;int 21h            ; Do MS-DOS call to print out value.
    
              pop ax             ; Restore value to AX.
              pop dx             ; Restore the loop counter.
              dec dx             ; Decrement loop counter.
              jnz nexthex        ; Loop back if there is another character
                                 ; to print.
    

    See here as well:

    http://www.masm32.com/board/index.php?PHPSESSID=fa4590ba57dbaad4bc44088172af0b49&action=printpage;topic=14410.0

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am reading a book about Javascript and jQuery and using one of the
I'm making a simple page using Google Maps API 3. My first. One marker

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.