Fast Puts() ?
Hy,
I had an idea and it worked.
But it's not so special, isn't it?
(But it is fast)
[MPUTS.E]
include machine.e
sequence vc
vc=machine_func(13,0)
atom screen
if vc[1] then
screen = #B8000
else
screen = #B0000
end if
global procedure Mputs(object xy,sequence txt,object color)
object
tmp=0
string=repeat(0,length(txt)*2)
xy=xy-1
for a=1 to length(string)/2 do
string[a+tmp]=txt[a]
string[a+tmp+1]=color
tmp+=1
end for
string_space=allocate(length(string)+1)
screen_location=screen+xy[1]*80*2+xy[2]*2
string_copy_code =
{#50, -- push eax
#53, -- push ebx
#52, -- push edx
#B8} & -- mov eax,
int_to_bytes(string_space) & -- string address (source)
{#BA} & -- mov edx,
int_to_bytes(screen_location) & -- screen address (destination)
{#8A, #18, -- L1: mov bl, [eax]
#40, -- inc eax
#88, #1A, -- mov [edx],bl
#83, #C2, #01, -- add edx, #1
#80, #38, #00, -- cmp byte ptr [eax], #00
#75, #F3, -- jne L1
#5A, -- pop edx
#5B, -- pop ebx
#58, -- pop eax
#C3} -- ret
code_space=allocate(length(string_copy_code))
poke(code_space,string_copy_code)
poke(string_space,string&0)
call(code_space)
free(code_space)
free(string_space)
end procedure
[EOF]
Bye,
PQ
QC
Get Your Private, Free Email at http://www.hotmail.com
|
Not Categorized, Please Help
|
|