Hello, hello.
lo-byte and hi-byte to an integer?
how does that go please in trse?
hi = $34 $56 $77 ...
lo = $00 ,$00 , $00 ...
Result should always be:
$3400 $5600 ......
lo-byte is always 00
Thank you.
grudd
TRSE : lo-byte and hi-byte to an integer.
Moderator: Moderators
- AndyH
- Vic 20 Afficionado
- Posts: 368
- Joined: Thu Jun 17, 2004 5:51 am
- Website: https://www.hewco.uk
- Location: UK
- Occupation: Developer
Re: TRSE : lo-byte and hi-byte to an integer.
Several ways I guess. Here's one:
Code: Select all
program Vic16k;
@startblock $2000 "code"
var
p1 : pointer;
i1 : integer = 0;
addrlo : array[] of byte = ($00, $01, $02);
addrhi : array[] of byte = ($10, $11, $10);
begin
definescreen();
// with a pointer
poke( p1, 0, addrlo[ 0 ]);
poke( p1, 1, addrhi[ 0 ]);
p1[0] := 1;
// with an integer
poke( i1, 0, addrlo[ 0 ]);
poke( i1, 1, addrhi[ 0 ]);
screenmemory := $1002;
printdecimal(i1, 4);
loop();
end.
Re: TRSE : lo-byte and hi-byte to an integer.
hello thanks for the help.
greeting.
greeting.
Re: TRSE : lo-byte and hi-byte to an integer.
the last two are wrongly calculated by the poke.
greeting
addrlo : array[] of byte = ($00, $01, $02);
addrhi : array[] of byte = ($10, $11, $10);
greeting
addrlo : array[] of byte = ($00, $01, $02);
addrhi : array[] of byte = ($10, $11, $10);
- AndyH
- Vic 20 Afficionado
- Posts: 368
- Joined: Thu Jun 17, 2004 5:51 am
- Website: https://www.hewco.uk
- Location: UK
- Occupation: Developer
Re: TRSE : lo-byte and hi-byte to an integer.
Ah yes, looking at the asm produced there is a bug in there. I was told by the author not to use peek and poke any longer as pointers were a more elegant solution. Here, try this instead:
Code: Select all
p1 := i1;
p1[0] := addrlo[ 2 ];
p1[1] := addrhi[ 2 ];
screenmemory := $1002;
printdecimal(i1, 4);
Re: TRSE : lo-byte and hi-byte to an integer.
hello thanks. is ok.
greeting
greeting