Author Topic: Addressing memorry from Assembler code  (Read 2532 times)

Stefan

  • Guest
Addressing memorry from Assembler code
« on: March 25, 2008, 01:46:09 PM »
Hello,

After more than 20years not having developed in assembler (last experience was on Intel 8085) I try to pick up again.
I develop a test board for driving step-motors controlled from the LPT1 port on an old PC.

Typically my code should have a delay loop with a parameter that sets the delay, and a sequence of 4bit paterns to be sent to the coils of the motor.
In this way I can change the speed of the motor, its direction etc.

In order to find where the base address of the lpt1 port is situated in my memory space, I found on the internet to check the double word on position 0040:0008. With the DOS Debugger I find the exact result.

Because it would be nice to develop later also a nice GUI for changing the parameters used in the assembler code, I started looking into RosAsm. BUT ... I have no way to address the DOS 0040:0008 space. I posted a message on the RosAsm forum and I got the suggestion to use an API etc. while the complete code for controlling the motors (2 because LPT1 allows to send 8bit out) can perfectly be done in RosAsm.

Betov suggested me to post my question on this forum.

Does somebody have a hint for me?

Thanks in advance,

Regards,

Stefan

nobody

  • Guest
Re: Addressing memorry from Assembler code
« Reply #1 on: March 25, 2008, 03:10:08 PM »
Well, Betov's right - use an API... if you want this for Windows. I don't know *which* API to use, but I'm sure there is one (or more) that will let you send any bit pattern you want to LPT1. And then you've got lots of APIs to handle the GUI-building.

But... how old is your "old PC"? If it's old enough that Windows is slow and cranky on it, you might be better off to stick with dos, and write your own GUI - as "fancy" and as much (or little) "like Windows" as you want.

If your program is intended to be "dedicated" to that one machine. I'd stick with dos. If it's intended to be run by "other people", Windows is a bit more popular these days...

The dos emulation under Windows may be an option - if it works as expected. Have you got any "working code", under any OS?

The "subject" is "addressing memory"... For dos, real or emulated...

...
push ds
push byte 40h ; segment of BDA
pop ds
mov ax, [8]
pop ds
mov [LPT1base], ax
...

But that isn't going to work in a Windows program (where the GUI stuff is available), regardless of whether it's written with RosAsm or Nasm.

For "what API", ask Microsoft... or, what I'd do, is google "lpt1 windows" or some such, and follow the MS link - probably easier than searching MS for it. :)

The dos approach seems "more interesting" to me, and is probably more like what you did in the "good old days". This API programming is "almost like being in BASIC". :)

Best,
Frank

Stefan

  • Guest
Re: Addressing memorry from Assembler code
« Reply #2 on: March 25, 2008, 09:47:05 PM »
Hi,

May be some background info may illustrate my intensions.
The step motors will be mounted on a telescope mounting. Beside the motor drivers I will need also a CCD camera for image capture.

My old PC is using windows 98 as OS. I use as a start the LPT port, but if I could use later on the USB ports that would simplify my life from the point of view of connecting.

Win 98 is not anylonger supported by Microsoft, so as longas my PC works, I will use Win98. I have no commercial intensions at all, but if later on I could use a laptop it is may be necessary to migrate thesoft to more recent OS. Remaining OS independent avoids a lot of porting work, I understand.

In the mean time I found a lot of info on the web searching on LPT1 Windows API. I need now some time to analyse and make thelink with RosAsm.

I know already that in the API it is possible to use the CreateFile and WriteFile functions for opening the LPT1 port and to write bytes to it. The info I found is C++ based. I wonder whether this is really different from RosAsm.

Regards,

Stefan

nobody

  • Guest
Re: Addressing memorry from Assembler code
« Reply #3 on: March 26, 2008, 06:36:02 AM »
> Because it would be nice to develop later also a nice GUI
> for changing the parameters used in the assembler code

> I started looking into RosAsm.

Is GUI really prohibited in DOS ? ;-)

You indeed can access LPT from Windaube ... but you will have a problem with timing ... your step motor will step like drunk :-D