Ok another question :)

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}
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

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
Mem[$B800:Offset] := Ord(String[I]);

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



  • Oh and:

    if di is used (as in slicers answer to my last problem, es:[di]) does di need to be preserved also? (i.e. pop it onto the stack, then place it back again once its been used) ?

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!


In this Discussion