Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CALL ABSOLUTE and Assembly Programing
#1
Gentlemen:

I would like to try some assembly programming to see if it can be made to run faster than the OUT command. I understand the assembly equivalent of OUT is:

MOV DX,
MOV AL, n
OUT DX, AL

But the article from which I got this doesn't define n, AL and I have no clear understanding of the above. What defines the Port, what defines the Data?
Also, is CALL ABSOLUTE needed? How should it be handled? The
information I have is vague and incomplete.

Thanks in advance for your comments and suggestions.

Jack C.
Reply
#2
In the assembly code you gave, AL and DX are registers (in fact, AL is the less significant byte of AX). Assembly out takes the 1st value (16 bits) as the address, and the second value (8 bits) as the number to OUT, so

Code:
MOV DX, address
MOV AL, value
OUT DX, AL

This is done 'cause in 8086 assembly you can't pass actual numbers to OUT, but registers where those numbers are stored.

Anyways, appart from boundary checkings the QBasic OUT command translates in such an assembly sequence, so you won't gain much speed.

To use this in QB you have to assemble that code, that is, convert it to hex. Then you just poke it in a QB array, and use CALL ABSOLUTE to call that array.

The assembly can be easily done using MSDOS debug. For such a short program you can enter the commands and write down the codes it produces (each assembly instruction produces one or more bytes).

Then, in QB, you need to reserve some memory (easily done defining an array or a fixed length string), and poke those values you wrote down using VARPTR, VARSEG and the like.

That array is all that you need to pass to CALL ABSOLUTE.

As you see, this is a lot of work. Sincerely, I think that it doesn't deserve it. You won't gain much time replacing QB's OUT command.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#3
In fact, you'll probably find using OUT in QB is faster than calling an assembly routine as "OUT" will/should generate no more than 2 instructions.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)