cnCalc计算器论坛

 找回密码
 注册
搜索
查看: 7252|回复: 4

[89/92/V200] 用TIGCC搭建 Ti-89 开发环境的一点总结

[复制链接]
发表于 2012-4-21 10:40:16 | 显示全部楼层 |阅读模式
本帖最后由 FreeBlues 于 2012-4-21 10:50 编辑

用TIGCC搭建 Ti-89 开发环境的一点总结

经过一个晚上的试验,解决了各种莫名其妙的错误,终于搞定TIGCC的开发环境,把我走过的弯路总结一下,其他对TI有点兴趣的朋友就可以迅速搞起来了。

1、TIGCC的安装版本,选择那个最新的 0.96 Beta 10 这里下载:https://github.com/debrouxl/gcc4ti/wiki/Download 可以减少一部分莫名其妙的错误,比如之前我装的比这个版本旧,手动打开TiEmu,它死活不认,换了新版本,就没事了;
2、建议先安装GTK+的支持包,再安装TIGCC,GTK+ 在这里下载:
http://prdownloads.sourceforge.net/gladewin32/gtk-win32-2.6.10-rc1.exe?download
3、安装好上面两个软件后,打开TiGCC,在“File/Preferences/Trasfer ”  里设置目标机,就是你的程序准备放在哪里跑,选择TiEmu的安装目录下的执行文件就可以了;
4、编译过程中,可能会有各种莫名其妙的错误提示,开始时我也是一头雾水,查手册查语法,查了老半天程序确定一点问题都没有,后来才发现是IDE的配置文件存在不同步的问题,一旦你修改了配置很可能IDE暂时还没写进去,还按前面的配置去跑,于是就一堆错误,所以遇到这种情况就多点几下按钮,多等会儿,实在不行就把项目删除了重新建,当然最根本的解决办法是直接用命令行去编译;
5、环境搭建好之后可以用下面这两个程序来试验,经过我的环境验证,这两个程序没有任何问题,可以正常编译运行,如下:

a)验证C语言环境的程序1:
来自这里 http://debrouxl.github.com/gcc4ti/httigcc.html

#define SAVE_SCREEN
#define USE_TI89
#define USE_TI92PLUS
#define USE_V200
#include <graph.h>
#include <kbd.h>

void _main(void)
{  
  static WIN_RECT  rect = {0, 0, 100, 14};  
  ClrScr ();  
  FontSetSys (F_8x10);
  DrawStr (3, 3, "Hello world!", A_NORMAL);
  DrawClipRect (&rect, ScrRect, A_NORMAL);
  ngetchx ();
}

b)验证A68K汇编环境的程序2:
来自这里:http://members.chello.at/gerhard.kofler/kevin/ti89prog/asmnstb.htm

include "OS.h"
xdef _nostub
xdef _ti89
xdef _ti92plus
movem.l d4/a5,-(a7) ;save d4 and a5
move.l $c8,a5 ;place the ROM_CALL jump table into a5
pea.l 3840 ;size to allocate
            ;(same as move.l #3840,-(a7), but more optimized)
move.l HeapAllocPtr*4(a5),a0
jsr (a0) ;allocate the 3840 bytes
move.l a0,d4 ;save the address of the allocated handle to d4
tst.l d4
beq nomem ;if the pointer is NULL, quit the program
move.l #3840,(a7) ;size to copy
;This instruction is not really necessary because HeapAllocPtr will not modify the value which is
;already on the stack, but it is better not to rely on it.
pea.l $4c00 ;source: address of the screen
move.l d4,-(a7) ;destination: adress of the allocated handle
move.l memcpy*4(a5),a0
jsr (a0) ;save the screen
lea.l 12(a7),a7 ;clean up the stack
;beginning of the main program
move.l ScreenClear*4(a5),a0
jsr (a0) ;clear the screen
move.w #4,-(a7) ;look in the main folder
pea.l sym(PC) ;symbol to look for
move.l SymFindPtr*4(a5),a0
jsr (a0) ;search for the variable
addq.l #4,a7
move.w 12(a0),(a7) ;The handle of the symbol is located at offset 12 of the SYM_ENTRY structure.
move.l HeapDeref*4(a5),a0
jsr (a0) ;dereference the handle
move.w #4,(a7) ;pass the A_REPLACE attribute as an argument
pea.l 3(a0) ;skip the size of the variable and the zero byte at the beginning of the string
clr.l -(a7) ;pass x=0 and y=0 as arguments (We clear 4 bytes, 2 of them for x and 2 more for y.)
move.l DrawStr*4(a5),a0
jsr (a0) ;display the content of the string
lea.l 10(a7),a7 ;clean up the stack
move.l ngetchx*4(a5),a0
jsr (a0) ;wait for a keypress
;end of the main program
pea.l 3840 ;size to copy
            ;(same as move.l #3840,-(a7), but more optimized)
move.l d4,-(a7) ;source: adress of the allocated handle
pea.l $4c00 ;destination: address of the screen
move.l memcpy*4(a5),a0
jsr (a0) ;restore the screen
addq.l #8,a7
move.l d4,(a7)
move.l HeapFreePtr*4(a5),a0
jsr (a0) ;free the allocated handle
nomem:
addq.l #4,a7 ;clean up the stack
movem.l (a7)+,d4/a5 ;restore d4 and a5
rts
dc.b 0,'datafile'
sym: dc.b 0
;The format of the symbols is special: You have to put a zero byte at the beginning and at the
;end, and the pointer must point to the final 0, not to the beginning.



评分

参与人数 1金钱 +3 收起 理由
diameter + 3 啊哦~~

查看全部评分

 楼主| 发表于 2012-4-21 10:43:02 | 显示全部楼层
附上程序运行截图

C程序1:
screenshot001.png


A68K汇编程序2:
screenshot000.png
发表于 2013-3-22 21:26:19 | 显示全部楼层
这是个模拟器?
发表于 2013-4-28 19:53:31 | 显示全部楼层
tigcc的运行速度和 ti-89 的basic在速度上差别大不大啊
 楼主| 发表于 2013-6-18 22:20:31 | 显示全部楼层
chuxianbing 发表于 2013-4-28 19:53
tigcc的运行速度和 ti-89 的basic在速度上差别大不大啊

取决于程序的运算量, 一般小程序肯定看不出多少差别来
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|cnCalc计算器论坛

GMT+8, 2024-11-22 13:57 , Processed in 0.067733 second(s), 27 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表