Est-t-il possible de réaliser un poke à partir d'une chaîne Exec, comme en C lorsque l'on veut modifier la valeur d'une certaine adresse mémoire ?
Bien sûr

Les chaînes Exec ne sont que la sérialisation hexa d'un programme ASM, sans les deux octets de taille et l'ASM_TAG final.
(faut-il que je poste sur Yaronet peut-être ?)
Ce n'est pas nécessaire.
Quand j'ai dû construire une chaîne Exec pour je ne sais plus quoi/qui (mais c'était en 2009, d'après le commentaire), j'ai créé un script Perl (car c'est plus vite fait que du C/C++) qui traduit le contenu du programme ASM (fichier *.??z, issu du build de sources C / ASM - comme ça, tu mets ce que tu veux dedans) en chaîne Exec.
Cependant, bien sûr, il faut Perl pour tourner ce script. Ce n'est pas un problème sous *nix, mais c'est moins immédiat sous Windows, bien que des distributions comme ActivePerl soient faciles à installer.
Voici une copie de ttasm2exec.pl, qui est dans les sources de GCC4TI:
- Code: Select all
#!/usr/bin/perl -W
use strict;
# Trivial program to convert a TI-68k assembly file (.??z) to a TI-BASIC Exec string.
# Copyright (C) 2009 Lionel Debroux.
package main;
my $length;
my $filecontents;
my $unpackedfilecontents;
( ($#ARGV == 0) # A single argument...
&& (($ARGV[0] =~ m#.89z$#) || ($ARGV[0] =~ m#.9xz$#) || ($ARGV[0] =~ m#.v2z$#)) # ... which ends with {89z,9xz,v2z} and ...
&& (-f $ARGV[0]) # ... which is a path representing an actual file.
)
or die "Usage: ttasm2exec.pl <infile.{89z,9xz,v2z}>\n";
open(INFILE, $ARGV[0]) or die "Can't open $ARGV[0]: $!";
read(INFILE, $filecontents, -s INFILE);
close(INFILE);
if ((index ($filecontents, "**TI89**") != 0) && (index ($filecontents, "**TI92P*") != 0)) {
die "$ARGV[0] doesn't seem to be a file suitable for TI-68k calculators";
}
do {
use bytes;
# Get file size in bytes.
$length = length($filecontents);
print "Input file is $length bytes long (of which 91 bytes will be stripped).\n";
if ($length <= 93) { # 86 bytes for the header, 2 size bytes, 2 bytes for the empty relocation, 1 byte for the tag and 2 bytes for the trailing checksum.
die "$ARGV[0] is too short to be a valid ASM file";
}
$length -= 90;
$filecontents = substr($filecontents, 88, $length);
$length *= 2; # Number of hex digits is twice that of bytes.
$unpackedfilecontents = unpack ("H[$length]", $filecontents);
if (rindex($unpackedfilecontents, "f3") != $length - 2) {
warn "$ARGV[0] doesn't seem to be an assembly file, the Exec string that will be generated is unlikely to work !";
}
$length = length($unpackedfilecontents);
$unpackedfilecontents = substr($unpackedfilecontents, 0, $length - 2);
print "Exec \"$unpackedfilecontents\"\n";
} while (0);