A few questions I need help in, please :)

Hi all. I have a few questions.



1. If I wanted to display the value which is in a certain register on the screen,

how would I do that? (For example, I want to display on the screen the value of

whatever is in the AX register).



2. Is there any way that I could use real images in an assembly program?

How would I go about doing that?( Example: I have, lets say, 52 little

bitmaps, a deck of cards. I want to display some of these cards on the screen.

Is it possible to do that? If not, does anyone have any suggestions as to how

I could display things on the screen that at least look like cards?)



3. Is it possible to generate random numbers in an assembly program? How?

(If I wanted to generate a random number between 0 and 52, how would I do

that?)



Thats all for now. Im sorry for asking so many questions but I really need the

info.



Any help is appreciated.



Thanx




Comments

  • Sorry to dump this on you, but this is what I HATE!



    There is absolutely nothing you can do in a high-level language, for example C, that you can not do in assembly. Period.



    There are, on the other hand, PLENTY of things you can NOT do in a high-level language that are quite possible to do in assembly.



    There does not exist a single language out there that directly gives you the full power of assembly, besides, of course, assembly. In other words, there is no programming language that let's you do everything assembly can.





    : Hi all. I have a few questions.

    :

    : 1. If I wanted to display the value which is in a certain register on the screen,

    : how would I do that? (For example, I want to display on the screen the value of

    : whatever is in the AX register).



    Well, I'm assuming you want the value in decimal or hexadecimal. All you need to do is convert the binary to a string. Then print the string the way you have been printing any other string. I'll not go over algorithms to do this, first, there have been bunches of posts about it recently, secondly, it's not to hard to make or find, and thirdly, I just don't feel like it.

    :

    : 2. Is there any way that I could use real images in an assembly program?

    : How would I go about doing that?( Example: I have, lets say, 52 little

    : bitmaps, a deck of cards. I want to display some of these cards on the screen.

    : Is it possible to do that? If not, does anyone have any suggestions as to how

    : I could display things on the screen that at least look like cards?)

    :

    Of course! You've no doubt played solitaire in (X)Windows at some point in your life. If it can be done on the x86, and something so trivial as that can obviously be done, then it can be done in assembly. Every programming language eventually distills down to assembly language.



    Now, the how depends on what video mode you are in. If you want this to be a text mode program then it's possible to get some fairly nice graphics in a round about way, but no one does it, that I know of (no I'm not talking about ASCII Art). So, if you want actual images then you'll have to use a video mode.



    Now, the question is how low level you want to go, and how high quality you want the pictures to be. If you are actually going to do something with this program and I don't think you are, then you'd want to use high-res modes and you'd probably want to use VESA to handle more stuff. If you are just doing this for the fun of it, then you'll probably simply want to use mode 13h. (Of course if your bitmaps are 24-bit true color, then you'll need to use that color depth if you want them to look the same, but if they are 8-bit then any mode will work.)



    I'm assuming you are doing this in DOS, seeing as how Windows and Linux answer some/most of these problems with the Windows API or shared-libs.



    All you'll need to know then is how to use mode 13h and how to handle BMPs. There is plenty of information out there on how to use mode 13h and how to read BMPs. If you already know the algorithm for reading BMPs in a high-level language, like C/C++, then just convert that to assembly.



    : 3. Is it possible to generate random numbers in an assembly program? How?

    : (If I wanted to generate a random number between 0 and 52, how would I do

    : that?)

    :



    Yes and No, and more No than Yes. No, because there is no algorithm to make a random number, because by definition there is no algorithm to get a random number. The algorithm generating it would defeat the purpose. So, we don't have random number generators. Of course, we DO have pseudo-random number generators. These are just algorithms that generate random looking data and that cover the whole spread of numbers (ie it doesn't focus on any one place). These are actually fairly simple algorithms.



    Here's an algorithm ripped from the LPA prolog read.me.



    rn+1=(rn*6364136223846793005+8110242468091) mod 2^64.



    Well that answers the No part.



    However, randomness exists in real life, Heisenberg's Uncertainty Principle guarantees it. So, it is possible to get random data. On PII and better, there is a memory-mapped port that hooks to pretty much a thermometer that is used to generate random numbers.



    : Thats all for now. Im sorry for asking so many questions but I really need the

    : info.

    :

    : Any help is appreciated.

    :

    : Thanx

    :

    :






Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories