The AsmPrgm command allows you to write programs in assembly, the native language of a calculator.
To run an Asm program, select Asm( from the catalog and your program from the program menu.
The commands in assembly are a little intimidating at first because they are in hex, however this not as big of a problem as it seems. All commands are some multiple of 2 hexadecimal digits.
All hex-codes of the assembly commands can be found in the TASM80.TAB file, which is included with the TASM assembler.
- C9 Returns to the calling program or home screen: ALWAYS put this at the end of your programs or your ram will clear.
- EF6A48 refreshes the graph screen
The load commandsEdit
40 to 7F: The load commands, loads a value into one of the eight 8-bit registers from another one.
The order of the registers is slightly confusing: each register has a value on the calc, which we will call R: b-0 c-1 d-2 e-3 h-4 l-5 (hl)-6 a-7
For the register you want to load into, add 40+8R For the register you want to load from, add R to the total you just got.
To load a value into a register, add 06+8R, then the 2 digit hex value you wish to load into that register.
The h and l registers are the registers which will give you an address (for example the adresses of 93 in h and 40 in l to 96 in h and 3F in l are the graph screen) while the (hl) register will modify the value in that adress. For example, a simple assembly program to write 4 dots in the upper left hand column of the screen is
:AsmPrgm :2693 Load 0x93 to h :2E40 load 0x40 to l :3655 load 0x55 (01010101 in binary) to (hl) :C9 Return
To jump in your programs based on the value in register b, make the command 10HH where HH is the hexadecimal value FF-however many bytes you want to jump back by, or however many bytes you want to jump forward by. It will decrease b by 1 and make the jump unless the value of b is zero.
The stack is a way to store values and keep them from being overwritten: the registers are paired for this. To add a pair to the stack, (push) bc-C5 de-D5 hl-E5, af-F5 To take them back off (pop) bc-C1 de-D1 hl-E1 af-F1 the last number onto the stack is the first one off. When you pop a pair of registers, any values you may have stored in those registers before you popped them will be overwritten. You must push anything you wish to save the value of before refreshing the screen. You must always have the same number of popped registers as you push at the end of the program.
A simple counting program:
:AsmPrgm :06FF load b, $FF :2693 load h, $93 :2E40 load l, $40 When modifying the entire hl register pair, use 21****. This saves one byte and four clock cycles. The first two digits of **** will be loaded into l; the second two will be loaded into h. (214093 results in l=40 and h=93) :70 load (hl), b :C5 Push bc :EF6A48 refresh :C1 pop bc :10F6 decrease b by 1, jump back by 10 bytes :C9 return
This will make a small binary counter at the top of your screen for a few seconds.
TEMPORARY CHANGE: I cannot figure out how to edit the "Notes" section below. However, "76" (while it does share the theoretical mnemonic for ld (hl), (hl)) does not necessarily freeze and kill the calculator. Actually, it is the code for "HALT." To be fair, this does cause the calculator to execute NOPS until it receives an interrupt, so it may appear to kill the calculator. The calculator is actually just waiting for something you might not have ever given it. ;)
If anyone knows how to edit the "Notes" section accordingly, please make my change and delete this text. Thanks.
- ↑ Do not use 76 (load (hl) into (hl)): the calculator will freeze and die.
- ↑ This is actually the hl register, different from the (hl) register, and the hl register is a 16-bit (4 letter) adress which your calculator stores data at. Modifying the data in some registers can harm your calculator, but the graph screen is safe.
- ↑ h is the large register, l is the small one. so increase l if you want to change the adress by 1 and h if you want to increase it by 256.
- ↑ 0x93 represents 93 hexidecimal
- ↑ Two letters