Author Topic: 16bit Poke in [whatever Language you prefer]! :)  (Read 2473 times)

0 Members and 1 Guest are viewing this topic.

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.939
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
    • Awards
Probably the only one here who found this useful:
 
Code: [Select]

Procedure memw(address, data : integer);
begin
 Inline($ED/$5B/data/
         $2A/address/
         $73/
         $23/
         $72);
end;

The assembly looks like this:
 
Code: [Select]

poke16: LD DE,(data)
LD HL,(addr)
LD (HL),E
INC HL
LD (HL),D
RET

The BASIC interactive version could look like this (use a Memory Editor to Poke the bytes in):
 
Code: [Select]

LD E,(IX+00) --> DD,5E,00
LD D,(IX+01) --> DD,56,01
LD L,(IX+02) --> DD,6E,02
LD H,(IX+03) --> DD,66,03
LD (HL),E --> 73
INC HL --> 23
LD (HL),D --> 72
RET --> C9
 
 
I was using this a few years ago in Turbo Pascal & BASIC to poke 16bit values from an Array (in Turbo Pascal), and in BASIC using the memory to store a series of values (16bit in origin). The resulting program which was simply a Circle routine which originally came from the Amstrad CPC464 Manual. In BASIC the program was okay because of it's Lookup table to make everything display faster. In Turbo Pascal 3 the same program (in it's Pascal equivalent) was noticibly slower due to it been entirely calculated and nothing was going to change that unless it all the values were stored into an array. Remarkibly the resulting program was much faster.
 
In BASIC storing the result in memory and having a M/C routine in my BASIC program to take that information and drawing it would also prove to run faster than allowing BASIC to utilise it's lookup table. If I ever find that example again I'll send it in.
 
Unsure if a 16bit Poke proves to be faster than simply apply too BASIC pokes, perhaps because I'm taking a routine which takes straight to the machine.
like
0
No reactions
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3