Nakazoto / Hellorld

A collection of the greatest programming on the planet!
21 stars 3 forks source link

hellorld on a TI-74 BASICALC #10

Open muellermgmx opened 1 year ago

muellermgmx commented 1 year ago

Hi my name is Meinhard and I wrote a hellorld on my modern calculator. My model is only 35 years old. To write a machine language program a few steps are neccessary. First the TI-74 must be enhanced with the GETMEM, RELMEM, PEEK, POKE and EXEC subroutines. This I have done with my mass storage device. It's a Amtel microprocessor and a SD card reader that connects to the hexbus. With the subroutines I can do memory manipulation and start a program. So I wrote a BASIC program that pokes the machine language into the computers memory. With the EXEC subroutine I can start the program. Unfortunately it ends in a endless loop because I don't know how I can exit this program properly. By pressing the reset button it will break. Then the display buffer is shown by pressing SHIFT + 9. It shows a beautiful HELLORLD!

I hope this is ok for you?

BASIC sourcecode

with a lot of comments...

100 ! HELLORLD! challenge 110 ! Implementation of hellorld! an a TI-74 BASICALC 120 ! in machine language 130 ! MOV %>48,A -> write 'H' to A register 140 ! (HEX) 22 48 -> (DEZ) 34 72 150 ! STA @>208D -> write A register to memory 8333 160 ! (HEX) 8B 20 8D -> (DEZ) 139 32 141 170 ! JMP -2 -> jump to itself / endless loop 180 ! (HEX) E0 FE -> 224, 254 190 DATA 32,72,69,76,76,79,82,76,68,33 200 DATA 32,32,32,32,32,32,32,32,32,32 210 DATA 32,0 220 DATALENGTH=107! memory to allocate 230 STARTADDR=0! determined by GETMEM 240 OPEN #1,"12.",OUTPUT:! open serial output 250 PRINT #1,"":PRINT #1,""! linefeeds give space 260 PRINT #1,"reserve";DATALENGTH;"bytes of memory..." 270 CALL GETMEM(DATALENGTH,STARTADDR) 280 PRINT #1,"memory start address: ";STARTADDR 290 PRINT "startaddress:",STARTADDR:PAUSE 300 PRINT "writing machine language..."; 310 PRINT #1,"write machine language to memory..." 320 ADR=STARTADDR! ADR counts up for POKE 330 OFFSET=141! offset of the "video memory" 340 RESTORE 190! use this data lines 350 READ VALUE! read a data value 360 IF VALUE=0 THEN 450! finish 370 CALL POKE(ADR,34)! MOV %>xx,A 380 CALL POKE(ADR+1,VALUE)! xx 390 CALL POKE(ADR+2,139)! STA @>20xx 400 CALL POKE(ADR+3,32)! 20 410 CALL POKE(ADR+4,OFFSET)! xx 420 ADR=ADR+5 430 OFFSET=OFFSET-1 440 GOTO 350 450 !generates an endless loop 460 CALL POKE(ADR,0)! nop 470 CALL POKE(ADR+1,224)! jmp xx 480 ADR=ADR+2 490 CALL POKE(ADR,-2)! xx -> -2 -> 254 500 PRINT:PRINT "reading memory..."; 510 PRINT #1,"read the poked values back..." 520 PRINT #1,"" 530 FOR READADR=STARTADDR TO ADR! loop memory 540 CALL PEEK(READADR,VALUE)! get values 550 PRINT #1,"read at:";READADR;" value:";VALUE 560 NEXT READADR 570 PRINT #1,""! print out clues on serial... 580 PRINT #1,"press [shift] + [9] and [enter]" 590 PRINT #1,"to execute the assembly program." 600 PRINT #1,"" 610 PRINT #1,"Unfortunately it ends in an endless loop" 620 PRINT #1,"and nothing is displayed." 630 PRINT #1,"To break press RESET button and then" 640 PRINT #1,"[shift] + [9] and [enter] to show the" 650 PRINT #1,"video buffer with the result: HELLORLD!" 660 PRINT #1,"" 670 PRINT #1,"Type in CALL EXEC(";STARTADDR;")" 680 PRINT #1,"to run the machine program again or" 690 PRINT #1,"type in CALL RELMEM(";STARTADDR;")" 700 PRINT #1,"to release the memory." 710 CLOSE #1 720 PRINT:PRINT "press [shift]+[9] & [enter]...":PAUSE 730 PRINT " CALL EXEC (";STARTADDR;")";

Serial output

The output on serial (connected terminal to the Amtel) is the following:

reserve 107 bytes of memory... memory start address: 13920 write machine language to memory... read the poked values back...

read at: 13920 value: 34 read at: 13921 value: 32 read at: 13922 value: 139 read at: 13923 value: 32 read at: 13924 value: 141 read at: 13925 value: 34 read at: 13926 value: 72 read at: 13927 value: 139 read at: 13928 value: 32 read at: 13929 value: 140 read at: 13930 value: 34 read at: 13931 value: 69 read at: 13932 value: 139 read at: 13933 value: 32 read at: 13934 value: 139 read at: 13935 value: 34 read at: 13936 value: 76 read at: 13937 value: 139 read at: 13938 value: 32 read at: 13939 value: 138 read at: 13940 value: 34 read at: 13941 value: 76 read at: 13942 value: 139 read at: 13943 value: 32 read at: 13944 value: 137 read at: 13945 value: 34 read at: 13946 value: 79 read at: 13947 value: 139 read at: 13948 value: 32 read at: 13949 value: 136 read at: 13950 value: 34 read at: 13951 value: 82 read at: 13952 value: 139 read at: 13953 value: 32 read at: 13954 value: 135 read at: 13955 value: 34 read at: 13956 value: 76 read at: 13957 value: 139 read at: 13958 value: 32 read at: 13959 value: 134 read at: 13960 value: 34 read at: 13961 value: 68 read at: 13962 value: 139 read at: 13963 value: 32 read at: 13964 value: 133 read at: 13965 value: 34 read at: 13966 value: 33 read at: 13967 value: 139 read at: 13968 value: 32 read at: 13969 value: 132 read at: 13970 value: 34 read at: 13971 value: 32 read at: 13972 value: 139 read at: 13973 value: 32 read at: 13974 value: 131 read at: 13975 value: 34 read at: 13976 value: 32 read at: 13977 value: 139 read at: 13978 value: 32 read at: 13979 value: 130 read at: 13980 value: 34 read at: 13981 value: 32 read at: 13982 value: 139 read at: 13983 value: 32 read at: 13984 value: 129 read at: 13985 value: 34 read at: 13986 value: 32 read at: 13987 value: 139 read at: 13988 value: 32 read at: 13989 value: 128 read at: 13990 value: 34 read at: 13991 value: 32 read at: 13992 value: 139 read at: 13993 value: 32 read at: 13994 value: 127 read at: 13995 value: 34 read at: 13996 value: 32 read at: 13997 value: 139 read at: 13998 value: 32 read at: 13999 value: 126 read at: 14000 value: 34 read at: 14001 value: 32 read at: 14002 value: 139 read at: 14003 value: 32 read at: 14004 value: 125 read at: 14005 value: 34 read at: 14006 value: 32 read at: 14007 value: 139 read at: 14008 value: 32 read at: 14009 value: 124 read at: 14010 value: 34 read at: 14011 value: 32 read at: 14012 value: 139 read at: 14013 value: 32 read at: 14014 value: 123 read at: 14015 value: 34 read at: 14016 value: 32 read at: 14017 value: 139 read at: 14018 value: 32 read at: 14019 value: 122 read at: 14020 value: 34 read at: 14021 value: 32 read at: 14022 value: 139 read at: 14023 value: 32 read at: 14024 value: 121 read at: 14025 value: 0 read at: 14026 value: 224 read at: 14027 value: 254

press [shift] + [9] and [enter] to execute the assembly program.

Unfortunately it ends in an endless loop and nothing is displayed. To break press RESET button and then [shift] + [9] and [enter] to show the video buffer with the result: HELLORLD!

Type in CALL EXEC( 13920 ) to run the machine program again or type in CALL RELMEM( 13920 ) to release the memory.

Nakazoto commented 11 months ago

Heya, very cool! Ultimately though, we need some pictures of it running on the real deal hardware.

muellermgmx commented 10 months ago

Hi, here is my Update with pictures...

Hi my name is Meinhard and I wrote a hellorld on my modern TI-74 BASICALC calculator. My model is almost 36 years old. To write a machine language program a few steps are neccessary:

MassStorageDevice

Here the single steps:

  1. load the machine language into memory
RUN "100.hellorld.c74"
  1. start the machine language program (repeat if you want)
CALL EXEC(15024):PAUSE

TI-74_runprogram

TI-74_result

Here is the BASIC sourcecode of hellorld.c74 with a lot of comments to program the machine language:

  100 ! HELLORLD! challenge
  110 ! Implementation of hellorld! on TI-74 BASICALC
  120 ! in machine language
  130 ! MOV %>48,A        -> write 'H' to A register
  140 ! (HEX) 22 48       -> (DEZ) 34 72
  150 ! STA @>208D        -> write A register to memory 8333
  160 ! (HEX) 8B 20 8D    -> (DEZ) 139 32 141
  170 DATA 72,69,76,76,79,82,76,68,33,0
  180 DATALENGTH=142! memory to allocate
  190 STARTADDR=0! determined by GETMEM
  200 CALL GETMEM(DATALENGTH,STARTADDR)
  210 PRINT "writing machine language...";
  220 ADR=STARTADDR! ADR counts up for POKE
  230 ! clear screen buffer
  240 CALL POKE(ADR,34)! MOV %>xx,A
  250 CALL POKE(ADR+1,32)! xx
  260 ADR=ADR+2
  270 FOR VIDEOADR=141 TO 141-30 STEP -1! clear display
  280 CALL POKE(ADR,139)! STA @>20xx
  290 CALL POKE(ADR+1,32)! 20
  300 CALL POKE(ADR+2,VIDEOADR)! xx
  310 ADR=ADR+3
  320 NEXT VIDEOADR
  330 VIDEOADR=141-10! left chars blank
  340 ! write hellorld!
  350 READ VALUE
  360 IF VALUE=0 THEN 450! finish
  370 CALL POKE(ADR,34)! MOV %>xx,A
  380 CALL POKE(ADR+1,VALUE)! xx
  390 CALL POKE(ADR+2,139)! STA @>20xx
  400 CALL POKE(ADR+3,32)! 20
  410 CALL POKE(ADR+4,VIDEOADR)! xx
  420 ADR=ADR+5
  430 VIDEOADR=VIDEOADR-1
  440 GOTO 350
  450 !RETS Return from Subroutine -> 0A -> 10
  460 CALL POKE(ADR,10)
  470 PRINT:PRINT "Typein:  CALL EXEC(";STR$(STARTADDR);"):PAUSE"
  480 PAUSE

Here is the machine language program (memory dump). From 15024 to 15118 the display buffer is celared by spaces. (In the future I will find out a better way to do this.) From 15118 to 15163 the hellorld! is written At the end 15164 a rteturn from subroutine is called.

Adress     Value as
   DEZ     HEX  DEZ
 15024      22   34
 15025      20   32
 15026      8B  139
 15027      20   32
 15028      8D  141
 15029      8B  139
 15030      20   32
 15031      8C  140
 15032      8B  139
 15033      20   32
 15034      8B  139
 15035      8B  139
 15036      20   32
 15037      8A  138
 15038      8B  139
 15039      20   32
 15040      89  137
 15041      8B  139
 15042      20   32
 15043      88  136
 15044      8B  139
 15045      20   32
 15046      87  135
 15047      8B  139
 15048      20   32
 15049      86  134
 15050      8B  139
 15051      20   32
 15052      85  133
 15053      8B  139
 15054      20   32
 15055      84  132
 15056      8B  139
 15057      20   32
 15058      83  131
 15059      8B  139
 15060      20   32
 15061      82  130
 15062      8B  139
 15063      20   32
 15064      81  129
 15065      8B  139
 15066      20   32
 15067      80  128
 15068      8B  139
 15069      20   32
 15070      7F  127
 15071      8B  139
 15072      20   32
 15073      7E  126
 15074      8B  139
 15075      20   32
 15076      7D  125
 15077      8B  139
 15078      20   32
 15079      7C  124
 15080      8B  139
 15081      20   32
 15082      7B  123
 15083      8B  139
 15084      20   32
 15085      7A  122
 15086      8B  139
 15087      20   32
 15088      79  121
 15089      8B  139
 15090      20   32
 15091      78  120
 15092      8B  139
 15093      20   32
 15094      77  119
 15095      8B  139
 15096      20   32
 15097      76  118
 15098      8B  139
 15099      20   32
 15100      75  117
 15101      8B  139
 15102      20   32
 15103      74  116
 15104      8B  139
 15105      20   32
 15106      73  115
 15107      8B  139
 15108      20   32
 15109      72  114
 15110      8B  139
 15111      20   32
 15112      71  113
 15113      8B  139
 15114      20   32
 15115      70  112
 15116      8B  139
 15117      20   32
 15118      6F  111
 15119      22   34
 15120      48   72
 15121      8B  139
 15122      20   32
 15123      82  130
 15124      22   34
 15125      45   69
 15126      8B  139
 15127      20   32
 15128      81  129
 15129      22   34
 15130      4C   76
 15131      8B  139
 15132      20   32
 15133      80  128
 15134      22   34
 15135      4C   76
 15136      8B  139
 15137      20   32
 15138      7F  127
 15139      22   34
 15140      4F   79
 15141      8B  139
 15142      20   32
 15143      7E  126
 15144      22   34
 15145      52   82
 15146      8B  139
 15147      20   32
 15148      7D  125
 15149      22   34
 15150      4C   76
 15151      8B  139
 15152      20   32
 15153      7C  124
 15154      22   34
 15155      44   68
 15156      8B  139
 15157      20   32
 15158      7B  123
 15159      22   34
 15160      21   33
 15161      8B  139
 15162      20   32
 15163      7A  122
 15164      0A   10