News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

2-digit number loop

Started by jatharvey, August 31, 2007, 10:55:16 PM

Previous topic - Next topic

jatharvey

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

raymond

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
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

jdoe

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


jatharvey

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

dsouza123

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 ?

dsouza123

Figured out checking for a key press while waiting for a second for a Windows 32-bit console program.


[attachment deleted by admin]