flat assembler
Message board for the users of flat assembler.

Index > DOS > 2-digit number loop

Author
Thread Post new topic Reply to topic
jharvey



Joined: 31 Aug 2007
Posts: 2
jharvey 31 Aug 2007, 23:22
Hi

How do you write .asm code to show 2-digit number looping every half a second from 00,01,02,03,04,05,06,07,08,09,10,11,12......,99.

The screen should show a minus sign if there is a keyboard interrupt during the loop.

I need it urgently, would be very thankfullllll if someone could help.
Post 31 Aug 2007, 23:22
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1898
DOS386 01 Sep 2007, 09:45
> I need it urgently

Homework ?? Typical for PASCAL forums Sad

> .asm code to show 2-digit number

Use DIV instruction, 16-bit dividend , 8-bit divisor (10) Wink

> every half a second

$046C , see RBIL memory map

http://board.flatassembler.net/download.php?id=3093
Post 01 Sep 2007, 09:45
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1378
Location: Piraeus, Greece
Picnic 01 Sep 2007, 10:06
Here's one way to count from 00 to 99:
Code:
org 100h

xor ax,ax

go:
push ax
add  ax,3030h
xchg ah,al
int  29h
xchg ah,al
int  29h
mov  al,0dh
int  29h
mov  al,0ah
int  29h
pop ax
inc  al
aaa
cmp  ax,0909h
jbe  go
ret
    
Post 01 Sep 2007, 10:06
View user's profile Send private message Reply with quote
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1 01 Sep 2007, 10:41
Do this:
$|=1; for ('00' .. '99') { select(undef, undef, undef, 0.5); print("$_ "; }

PS: Sorry BAD joke!
Post 01 Sep 2007, 10:41
View user's profile Send private message Reply with quote
eek



Joined: 21 Oct 2006
Posts: 24
eek 01 Sep 2007, 13:27
This will do the counting bit for ya.

ZONE S L
org cs:100

mov bp,B800 ;printing
mov es,bp ;bit
mov di,722 ;
;
mov ax,9030
mov bx,11110000b
mov cx,9030

loop
es:mov [di],al
cmp al,39
jz Tens
inc di
inc di
es:mov b[di],","
inc di
inc di
inc ax
jmp loop
;
Tens
inc cx
inc di
inc di
es:mov b[di],","
inc di
inc di
and ax,bx
es:mov [di],cl


loop2
inc di
inc di
es:mov [di],al
cmp al,39
jz Tens
inc di
inc di
es:mov b[di],","
inc di
inc di
inc ax
mov bp,sp
mov dx,[bp]
es:mov b[di],cl
jmp loop2
;


END
[color=#][/color][color=#][/color][color=#][/color][color=#][/color][color=#][/color][color=#][/color]
Post 01 Sep 2007, 13:27
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 786
Location: Adelaide
sinsi 01 Sep 2007, 15:11
Code:
for x=0 to 9
  for y=0 to 9
    print str$("0"+x & "0"+y);" ";
    if user_pressed_a_key then print_a_minus
    wait(half_a_sec)
  next y
next x

print "this is my homework"
print "answer is from several ASM programming sites"
print "but (C)(R)(Tm) the_drunk_sinsi"
    

loser
Post 01 Sep 2007, 15:11
View user's profile Send private message Reply with quote
jharvey



Joined: 31 Aug 2007
Posts: 2
jharvey 02 Sep 2007, 02:58
Thank you guys!!!
Post 02 Sep 2007, 02:58
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.