Solved

How do I do this in assembly language

Posted on 2008-06-21
5
894 Views
Last Modified: 2008-06-29
I am stuck on how to get this problem solved, display a single character at 100 random screen locations, using a timing delay of 100 milliseconds.
INCLUDE Irvine32.inc
 
 

.data

;Get max xy vaiables

rows BYTE ?

cols BYTE ?

;Get milliseconds variable

startTime DWORD 100

;output character

char1 BYTE "S",0

.code

main PROC
 

call GetMaxXY

mov rows,dh

mov cols,dl

call GetMseconds

mov eax,startTime

mov ecx,100

L1: 

    mov dh,rows

    mov dl,cols

    call Gotoxy

    mov edx,OFFSET char1

    call WriteString

    loop L1

    call Crlf

    

call WaitMsg

    exit

main ENDP
 

END main

Open in new window

0
Comment
Question by:xudeus
  • 3
  • 2
5 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 21840061
Do you have some kind of Rand function available ? If so, make it calculate the next random x and y positions (between 0 and the maxX and maxY values) at the beginning of the loop.

Note that at the end of the loop you will want to decrement ecx, so it doesn't loop forever.

You'll also have to wait 100ms at the end of the loop.
0
 

Author Comment

by:xudeus
ID: 21840967
Ive tried that I get exception errors in the memory, Imust not have it coded correctly. heres what I have so far.
INCLUDE Irvine32.inc
 
 

.data

;Get max xy vaiables

rows BYTE ?

cols BYTE ?

;Get milliseconds variable

startTime DWORD 100

;output character

char1 BYTE "S",0

.code

main PROC
 

call GetMaxXY

mov rows,dh

mov cols,dl

call GetMseconds

mov eax,startTime

call Randomize

mov ecx,100

L1: call RandomRange

    mov dh,rows

    mov dl,cols

    call Gotoxy

    mov edx,OFFSET char1

    call WriteString

    loop L1

    call GetMseconds

    mov startTime,eax

    call Crlf

    

call WaitMsg

    exit

main ENDP
 

END main

Open in new window

0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21842156
What does your RandomRange function do ?

You still don't decrement ecx at the end of the loop. It's still gonna loop forever.
You're still not waiting 100ms at the end of the loop either.


>> Ive tried that I get exception errors in the memory,

Where ? Which exception ?
0
 

Author Comment

by:xudeus
ID: 21842596
I dont deincrement because it does not loop forever, as for the random range what that does is exactly what you asked me for in you initial post it finds a range between 0 and whatever the max is, it is a rand function. As for the milliseconds I dont really understand how to use it. I am extreme novice to assembly.
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 500 total points
ID: 21844178
>> I dont deincrement because it does not loop forever

My mistake ... I didn't notice that you used the loop instruction to perform the loop. Ignore what I said about ecx ;)



>> as for the random range what that does is exactly what you asked me for in you initial post it finds a range between 0 and whatever the max is,

I mean ... what's its input (is it passed on the stack ?), and what's its output (will it be in eax ?).


>> As for the milliseconds I dont really understand how to use it.

Then let's keep that for later. Let's focus on getting the random positions to work first.


I would suggest to :

1) First try to place a character on the (0,0) position.
2) When that works, try calculating a random position, and place a character there.
3) When that works, put the whole thing in a loop, so that 100 characters are shown in random positions.
4) When that works, you can add the 100ms delay.


Let me know, at which of the above 4 steps you have a problem.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help! Bomb phase 6 3 976
Picking random number 8 175
Monitor or record changes to an application in memory 5 284
abcpdf error 3 807
There are many Password Managers (PM) out there to choose from. PM's can help with your password habits and routines, but they should not be a crutch you rely on too heavily. I also have an article for company/enterprise PM's.
An analysis of the phishing scam that has been affecting Google users, along with steps to take for protection, as well as what to do if you receive one of the emails.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now