;--------------------------------------------------------------------------- ; Machine Language Program #2: A Memory Dumper ;--------------------------------------------------------------------------- To demonstrate the methods discussed in my post "Hacking the TI-85", and to provide a useful utility for TI hacking, I have written a new machine language program: a memory dumper that runs on your TI-85. The source code and an .85B file of the program is included at the end of this posting. To use the program: (1) Transfer the file DUMP.85B to your TI. (2) Press the CLEAR button, so the cursor is in the upper left hand corner of the screen. (3) Enter the page # and memory address in HEX. For example, to dump page #0, address 33D9, enter 033D9 (4) Select "Dump" from the CUSTOM menu At this point the screen will look like: +---------------------+ |033D9 | |33D9 E3 F5 D5 5E ...^| |33DD 23 56 23 7E #V#~| |33E1 D3 05 EB D1 .../| |33E5 F1 E3 C9 CD ....| |33E9 AC 33 38 7D .38}| |33ED 06 CD AC 33 ...3| |33F1 7B 7D 06 CD {}..| +---------------------+ This is very useful when you want to browse around memory & don't have the time to transfer files back and forth between your TI and computer. If you try this out, please send an e-mail to adb2y@virginia.edu, and tell me if you got it to work, or if you ran into any problems. ;--------------------------------------------------------------------------- ; A Few Notes ;--------------------------------------------------------------------------- (1) Using this program, I have discovered that some of the information in the section "The Structure of a .85B File" is incorrect - there is NOT a simple 1-to-1 correspondence between bytes in the .85B file and bytes in RAM. The actual correspondence will be discussed in the revised version of "Hacking the TI-85" (2) The text screen starts at 80DF, NOT 80DD as I stated in "Hacking the TI-85" (3) One of the topics I omitted in "Hacking the TI-85" is the TI's memory paging system. As far as I can tell, the memory map is: 0000 - 3FFF ROM Not Paged 4000 - 7FFF ROM Paged 8000 - ???? RAM Not Paged To switch memory pages, do the following: LD A, Page# OUT ($05), A This will change the bytes in the range 4000 - 7FFF. You can see this for yourself by using my Dump program. (4) The memory dump of 33D9 which I used as an example of the Dump program is a little procedure that the TI uses for CALLing subroutines in other pages :). For more info, disassemble the code, or wait for the next release of "Hacking the TI-85" where paging will be discussed in more detail. ;--------------------------------------------------------------------------- ; The Source Code for "Dump" ;--------------------------------------------------------------------------- 0001 0000 ;====================================================== 0002 0000 ; Dump 0003 0000 ;====================================================== 0004 0000 ; Dump is a memory dump utility for the TI-85 0005 0000 ; calculator. To use Dump, CLEAR the screen (so the 0006 0000 ; cursor is in the upper left hand corner), enter the 0007 0000 ; page number and address to be dumped (in HEX), and 0008 0000 ; select "Dump" from the CUSTOM menu. 0009 0000 ;------------------------------------------------------ 0010 0000 0011 0000 TEXT_ADDR .EQU $80DF ; Addr. of text memory 0012 0000 VIDEO_ADDR .EQU $8641 ; Addr. of video memory 0013 0000 QUIT_ADDR .EQU $0462 ; Addr. of QUIT 0014 0000 LINE_LEN .EQU $15 ; # of chars on 1 line 0015 0000 0016 8641 .ORG VIDEO_ADDR 0017 8641 0018 8641 ; 0019 8641 ; Set up the CUSTOM menu data structure 0020 8641 ; 0021 8641 41 00 07 C3 .BYTE $41, $00, $07, $C3 0022 8645 4C 86 .WORD Start 0023 8647 44 75 6D 70 .TEXT "Dump" 0024 864B 00 .BYTE $00 0025 864C 0026 864C Start: 0027 864C 11 00 00 LD DE, $0000 0028 864F 21 DF 80 LD HL, TEXT_ADDR 0029 8652 0030 8652 CD 9B 86 CALL Parse_character 0031 8655 FE FF CP $FF 0032 8657 28 02 JR Z, Parse_loop 0033 8659 D3 05 OUT ($05), A 0034 865B 0035 865B Parse_loop 0036 865B CD 9B 86 CALL Parse_character 0037 865E FE FF CP $FF 0038 8660 28 0C JR Z, Done 0039 8662 06 04 LD B, $04 0040 8664 Shift_4: 0041 8664 CB 23 SLA E 0042 8666 CB 12 RL D 0043 8668 10 FA DJNZ Shift_4 0044 866A 83 ADD A, E 0045 866B 5F LD E, A 0046 866C 18 ED JR Parse_loop 0047 866E Done: 0048 866E 21 F4 80 LD HL, TEXT_ADDR+LINE_LEN 0049 8671 06 07 LD B, $07 0050 8673 Line_loop: 0051 8673 C5 PUSH BC 0052 8674 ; 0053 8674 ; Print out the address (4 characters) 0054 8674 ; 0055 8674 7A LD A, D 0056 8675 CD B8 86 CALL Print_byte 0057 8678 7B LD A, E 0058 8679 CD B8 86 CALL Print_byte 0059 867C ; 0060 867C ; Print a space (1 character) 0061 867C ; 0062 867C CD B3 86 CALL Print_space 0063 867F ; 0064 867F ; Print out 4 hexadecimal bytes (12 characters) 0065 867F ; 0066 867F D5 PUSH DE 0067 8680 06 04 LD B, $04 0068 8682 Hex_loop: 0069 8682 1A LD A, (DE) 0070 8683 CD B8 86 CALL Print_byte 0071 8686 CD B3 86 CALL Print_space 0072 8689 13 INC DE 0073 868A 10 F6 DJNZ Hex_loop 0074 868C ; 0075 868C ; Print out 4 ASCII characters (4 characters) 0076 868C ; 0077 868C D1 POP DE 0078 868D 06 04 LD B, $04 0079 868F ASCII_loop: 0080 868F 1A LD A, (DE) 0081 8690 77 LD (HL), A 0082 8691 13 INC DE 0083 8692 23 INC HL 0084 8693 10 FA DJNZ ASCII_loop 0085 8695 0086 8695 C1 POP BC 0087 8696 10 DB DJNZ Line_loop 0088 8698 C3 62 04 JP QUIT_ADDR 0089 869B 0090 869B ;------------------------------------------------------ 0091 869B ; Parse the character at (HL). On return: 0092 869B ; A = 00-0F if character is a HEX digit 0093 869B ; A = FF if character is not a HEX digit 0094 869B ;------------------------------------------------------ 0095 869B Parse_character: 0096 869B 7E LD A, (HL) 0097 869C 23 INC HL 0098 869D D6 30 SUB '0' 0099 869F 38 0F JR C, Not_HEX 0100 86A1 FE 0A CP $0A 0101 86A3 38 0A JR C, Less_10 0102 86A5 D6 07 SUB 7 0103 86A7 FE 0A CP $0A 0104 86A9 38 05 JR C, Not_HEX 0105 86AB FE 10 CP $10 0106 86AD 30 01 JR NC, Not_HEX 0107 86AF Less_10: 0108 86AF C9 RET 0109 86B0 Not_HEX: 0110 86B0 3E FF LD A, $FF 0111 86B2 C9 RET 0112 86B3 0113 86B3 ;------------------------------------------------------ 0114 86B3 ; Print a space character 0115 86B3 ;------------------------------------------------------ 0116 86B3 Print_space: 0117 86B3 3E 20 LD A, ' ' 0118 86B5 77 LD (HL), A 0119 86B6 23 INC HL 0120 86B7 C9 RET 0121 86B8 0122 86B8 ;------------------------------------------------------ 0123 86B8 ; Print the byte in A 0124 86B8 ;------------------------------------------------------ 0125 86B8 Print_byte: 0126 86B8 F5 PUSH AF 0127 86B9 CB 3F SRL A 0128 86BB CB 3F SRL A 0129 86BD CB 3F SRL A 0130 86BF CB 3F SRL A 0131 86C1 CD CB 86 CALL Print_nybble 0132 86C4 F1 POP AF 0133 86C5 E6 0F AND 0F 0134 86C7 CD CB 86 CALL Print_nybble 0135 86CA C9 RET 0136 86CB 0137 86CB ;------------------------------------------------------ 0138 86CB ; Print the low order nybble of A 0139 86CB ;------------------------------------------------------ 0140 86CB Print_nybble: 0141 86CB C6 30 ADD A, '0' 0142 86CD FE 3A CP $3A 0143 86CF 38 02 JR C, Less_0A 0144 86D1 C6 07 ADD A, $07 0145 86D3 Less_0A: 0146 86D3 77 LD (HL), A 0147 86D4 23 INC HL 0148 86D5 C9 RET 0149 86D6 0150 86D6 .END tasm: Number of errors = 0 ;--------------------------------------------------------------------------- ; The DUMP.85B File ;--------------------------------------------------------------------------- begin 644 dump.85b M*BI423@U*BH:#`!"86-K=7`@9FEL92!D871E9"`P.2\P,R\Y-"P@,3(Z-38` M+@!5)_5=KI+W"`D`L0@=$@`C`/>+L0@``!`!``````P(```P$@`````%```` M`````````````````&.$;81WA(&$BX25A``````````````````````````` M````@@```/P```````````#\8H,84P<8``#_^Q,(F6DXF5<``/P````````` M``#\````````````_&*#&%,'&```__L3")EI.)E7@`'\$``````````!_!`` M`````````/P0````````@`'\$``````````!_!```````````/P0```````` M`/W[$`````````#[^Q```````````/Q```````````#\0`````````#_^Q6' M,!6',!8`__LR)8!D46$I``#\8P``````````_#$```````!1``"``?P0```` M``````'\$```````````_!````````"``?P0``````````'\$``````````` M_!````````"``?P0``````````'\$````````%L`````_````````````/QB M@QA3!Q@``/_[$PB9:3B95X`!_!```````````?P0``````````#\$``````` M`(`!_!```````````?P0``````````#\$````````%L`````_``````````` M`/QB@QA3!Q@``/_[$PB9:3B95X`!_!```````````?P0``````````#\$``` M`````(`!_!```````````?P0``````````#\$````````'$```#]^Q`````` M`````/P```````````#\````````````_&*#&%,'&```__L3")EI.)E7@`'\ M$``````````!_!```````````/P0````````@`'\$``````````!_!`````` M`````/P0`````````!``]_\``/?_``#W_P`````````````````````````` M```````````````````````````````````````````````````````````` M````````````````````````````00`'PTR&1'5M<``1```AWX#-FX;^_R@" MTP7-FX;^_R@,!@3+(\L2$/J#7QCM(?2`!@?%>LVXAGO-N(;-LX;5!@0:S;B& MS;.&$Q#VT08$&G<3(Q#ZP1#;PV($?B/6,#@/_@HX"M8'_@HX!?X0,`')/O_) M/B!W(\GURS_+/\L_RS_-RX;QY@_-RX;)QC#^.C@"Q@=W(\D````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````$_!(T4```````!/QGB0`````````````````````````` M`````````"`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@ M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@ M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@ M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@(``````` M``F,"8Q+^DOZ`````/?_````````````!P```````````/\````````````` M```````````````````````````````````````````````````````````` M`````````````````````````````````````````````/?_```````````` M````````````````````````"0]!A@`````````````````````````````` M````````1&X`]__W_UWZ]_\)C`F,"8Q,^DSZ`````$SZ`````````````!(` M````````_```````````````(P`A`8P'$B,!C`42