The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: jatharvey on August 31, 2007, 10:55:16 PM

Title: 2-digit number loop
Post by: jatharvey on August 31, 2007, 10:55:16 PM
Hi

How do you write an assembler code in .asm to show 2 digit number looping, starting from 00 upto 99.
The numbers should keep looping from 00,01,02,03,04,05,06,07,08,09,10,11,12......99. When the user
enters the keyboard during the loop, the screen should stop looping and only show a minus sign.

I would really appreciate if somebody out there can help ASAP!!!!

Thanks a million
Title: Re: 2-digit number loop
Post by: raymond on August 31, 2007, 11:40:47 PM
Sounds like HOMEWORK to me. :naughty: :naughty: :naughty:

1- You forgot to mention which assembler you intend to use. The syntax can be quite different between assemblers.
2- You forgot to mention if it must be in 16-bit DOS or 32-bit.
3- You forgot to mention if you must access the video hardware directly or use functions available with your operating system to display on the monitor.
4- You forgot to indicate the length of the interval between the display of each number.
5- You forgot to mention the name of your teacher!!!!

Raymond
Title: Re: 2-digit number loop
Post by: jdoe on September 01, 2007, 02:51:11 AM
Quote from: jatharvey on August 31, 2007, 10:55:16 PM

The numbers should keep looping from 00,01,02,03,04,05,06,07,08,09,11,12......99. When the user


So it have to skip number 10. Nice challenge !!!


Quote from: raymond on August 31, 2007, 11:40:47 PM

5- You forgot to mention the name of your teacher!!!!



:lol   :lol   :lol

Title: Re: 2-digit number loop
Post by: jatharvey on September 01, 2007, 04:03:38 AM
Hi Raymond

The program is to be run in a DOS 6.22 environment. I assumed it is 32 bits. Length of interval is 1 second, the numbers are to be displayed on the monitor.

I just need a really basic code.

Thanks
Title: Re: 2-digit number loop
Post by: dsouza123 on September 01, 2007, 02:58:33 PM
D0S 6.22 is normally 16 bit, but with DOS extenders 32-bit protected mode can also be done.
Windows 32-bit also has console mode in which text based programs look just like DOS 16-bit.

A high level outline :


  keypressed = 0
  number = 0
 
  while keypressed == 0
    print number
    keypressed = wait_with_keyboard_check, 1000   ; 1000 is one thousand milliseconds aka one second
    if keypressed != 0
      print '-'
    else
      number = number + 1
      if number > 99
        number = 0
      endif
    endif
  endw


The hard part is the code for waiting a second while checking for keyboard input.

==============================

How could this be done as a Windows 32-bit console mode program ?

Especially the checking for keyboard input while doing a one second wait ?
Title: Re: 2-digit number loop
Post by: dsouza123 on September 01, 2007, 09:46:03 PM
Figured out checking for a key press while waiting for a second for a Windows 32-bit console program.


[attachment deleted by admin]