Ok another question :) - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Ok another question :)

StarburnStarburn Posts: 17Member
Ive just written this code:
(Ok it might not be perfect (yet).. but it works :) )

procedure WriteXY(X, Y : byte; {Text : string}); assembler;
{Extra code is needed for X and Y to be variables of type byte}
asm
xor bx, bx {Clear BX}
xor cx, cx {Clear CX}
mov cl, Y {Move Y into Counter (last 8 bits)}
dec cx {Take 1 from Counter}
@loop1: {(because of dec cx) "For I := 1 to (Y - 1)"}
add bx, 80 {Inc bx by 80 (Inc(Offset,80))}
loop @loop1 {End loop}
mov cl, X {Move X into cl (cx = 0 from loop)}
add bx, cx {Add X to bx (Inc(Offset,X))}
dec bx {(This and next line) Offset := (Offset - 1) * 2}
add bx, bx {Multiply bx by 2}
push es {Preserve segment reg.}
mov ax, $B800 {Move Screen mem segement into ax}
mov es, ax {ax into es}
mov byte ptr es:[bx],1 {Move Char 01 into $B800:Offset}
pop es
end;

Now, ive hit a wall... that I didnt think of.
I have no idea how to handle arrays of chars (strings) in assembler :/.

I was thinking (in normal pascal):

for I := 1 to length(String) do
begin
Mem[$B800:Offset] := Ord(String[I]);
Inc(Offset)
end;

although, can anybody give me any help on how to do this with the inline assembler? Or a web link?

Thanks,
-Matt.

Comments

Sign In or Register to comment.