; definitions file for busra.asm ; Copyright (c) 2011 Andrew Owen ; X80 maths co-processor instruction set (requires macro support) ; never called directly: ; ; ftop ; fbor ; fband ; fbands ; fcps (6 opcodes) ; fvals ; fusrs ; fread ; fasc ; fval ; flen ; ftan ; facos ; fexp ; fsgn ; fpeek ; fin ; fusr ; fstrs ; fchrs ; fetof ; parameter definitions ; (period used to distinguish from assembler commands) .le equ 0 ; less than or equal .ge equ 1 ; greater or equal .ne equ 2 ; not equal .gt equ 3 ; greater than .lt equ 4 ; less than .eq equ 5 ; equal .lz equ 2DH ; less than zero .gz equ 2EH ; greater than zero ; instruction macros MACRO fwait ; stop the Z80 rst 28h ENDM MACRO fjpt, n ; jump if true defb 0x00, n ENDM MACRO fxch ; exchange defb 0x01 ENDM MACRO fdel ; delete defb 0x02 ENDM MACRO fsub ; subtract defb 0x03 ENDM MACRO fmul ; multiply defb 0x04 ENDM MACRO fdiv ; divide defb 0x05 ENDM MACRO ftop ; to power defb 0x06 ENDM MACRO fbor ; binary or defb 0x07 ENDM MACRO fband ; binary and defb 0x08 ENDM MACRO fcp, n ; compare (.le ... gtz) defb 0x09 + n ENDM MACRO fadd ; add defb 0x0f ENDM MACRO fbands ; binary and string defb 0x10 ENDM MACRO fcps, n ; compare string (.le to .eq) defb 0x11 + n ENDM MACRO fcat ; concatenate string defb 0x17 ENDM MACRO fvals ; value string defb 0x18 ENDM MACRO fusrs ; user string defb 0x19 ENDM MACRO fread ; read in defb 0x1a ENDM MACRO fneg ; negate defb 0x1b ENDM MACRO fasc ; character to ASCII defb 0x1c ENDM MACRO fval ; value defb 0x1d ENDM MACRO flen ; length of string defb 0x1e ENDM MACRO fsin ; sine defb 0x1f ENDM MACRO fcos ; cosine defb 0x20 ENDM MACRO ftan ; tangent defb 0x21 ENDM MACRO fasin ; arcsine defb 0x22 ENDM MACRO facos ; arccosine defb 0x23 ENDM MACRO fatan ; arctangent defb 0x24 ENDM MACRO flogn ; natural logarithm defb 0x25 ENDM MACRO fexp ; exponential defb 0x26 ENDM MACRO fint ; integer (rounded down) defb 0x27 ENDM MACRO fsqrt ; square root defb 0x28 ENDM MACRO fsgn ; signum defb 0x29 ENDM MACRO fabs ; absolute value defb 0x2a ENDM MACRO fpeek ; PEEK defb 0x2b ENDM MACRO fin ; IN defb 0x2c ENDM MACRO fusr ; user address defb 0x2d ENDM MACRO fstrs ; string defb 0x2e ENDM MACRO fchrs ; character defb 0x2f ENDM MACRO fnot ; not defb 0x30 ENDM MACRO fmove ; move defb 0x31 ENDM MACRO fmod ; modulus defb 0x32 ENDM MACRO fjp, n ; jump defb 0x33, n ENDM MACRO fstk ; stack data defb 0x34 ENDM MACRO fdjnz, n ; djnz defb 0x35, n ENDM MACRO fce ; chip enable defb 0x38 ENDM MACRO fget ; get defb 0x39 ENDM MACRO ftrn ; truncate defb 0x3a ENDM MACRO fsgl ; single operation defb 0x3b ENDM MACRO fetof ; e to floating-point defb 0x3c ENDM MACRO frstk ; restack defb 0x3d ENDM MACRO fstk0 ; stack 0 defb 0xa0 ENDM MACRO fstk1 ; stack 1 defb 0xa1 ENDM MACRO fstk.5 ; stack half defb 0xa2 ENDM MACRO fstkpix.5 ; stack pi/2 defb 0xa3 ENDM MACRO fstk10 ; stack 10 defb 0xa4 ENDM MACRO fst, n ; store (mem 0-5) defb 0xc0 + n ENDM MACRO fgt, n ; get (mem 0-5) defb 0xe0 + n ENDM ;colours black equ 0x00 blue equ 0x01 red equ 0x02 magenta equ 0x03 green equ 0x04 cyan equ 0x05 yellow equ 0x06 white equ 0x07 ;control characters ctrl_true_vid equ 0x04 ctrl_inv_vid equ 0x05 ctrl_caps equ 0x06 ctrl_comma equ 0x06 ctrl_edit equ 0x07 ctrl_left equ 0x08 ctrl_right equ 0x09 ctrl_down equ 0x0a ctrl_up equ 0x0b ctrl_delete equ 0x0c ctrl_enter equ 0x0d ctrl_symbol equ 0x0e ctrl_number equ 0x0e ctrl_graphics equ 0x0f ctrl_ink equ 0x10 ctrl_paper equ 0x11 ctrl_flash equ 0x12 ctrl_bright equ 0x13 ctrl_inverse equ 0x14 ctrl_over equ 0x15 ctrl_at equ 0x16 ctrl_tab equ 0x17 ;printable characters pchr_pound equ '`' pchr_copyright equ 0x7f ;tokens tk_rnd equ 0xa5 tk_inkey_str equ 0xa6 tk_pi equ 0xa7 tk_fn equ 0xa8 tk_point equ 0xa9 tk_screen_str equ 0xaa tk_attr equ 0xab tk_at equ 0xac tk_tab equ 0xad tk_val_str equ 0xae tk_code equ 0xaf tk_val equ 0xb0 tk_len equ 0xb1 tk_sin equ 0xb2 tk_cos equ 0xb3 tk_tan equ 0xb4 tk_asn equ 0xb5 tk_acs equ 0xb6 tk_atn equ 0xb7 tk_ln equ 0xb8 tk_exp equ 0xb9 tk_int equ 0xba tk_sqr equ 0xbb tk_sgn equ 0xbc tk_abs equ 0xbd tk_peek equ 0xbe tk_in equ 0xbf tk_usr equ 0xc0 tk_str_str equ 0xc1 tk_chr_str equ 0xc2 tk_not equ 0xc3 tk_bin equ 0xc4 tk_or equ 0xc5 tk_and equ 0xc6 tk_l_eql equ 0xc7 tk_gr_eq equ 0xc8 tk_neql equ 0xc9 tk_line equ 0xca tk_then equ 0xcb tk_to equ 0xcc tk_step equ 0xcd tk_def_fn equ 0xce tk_cat equ 0xcf tk_format equ 0xd0 tk_move equ 0xd1 tk_erase equ 0xd2 tk_open equ 0xd3 tk_close equ 0xd4 tk_merge equ 0xd5 tk_verify equ 0xd6 tk_beep equ 0xd7 tk_circle equ 0xd8 tk_ink equ 0xd9 tk_paper equ 0xda tk_flash equ 0xdb tk_bright equ 0xdc tk_inverse equ 0xdd tk_over equ 0xde tk_out equ 0xdf tk_lprint equ 0xe0 tk_llist equ 0xe1 tk_stop equ 0xe2 tk_read equ 0xe3 tk_data equ 0xe4 tk_restore equ 0xe5 tk_new equ 0xe6 tk_border equ 0xe7 tk_continue equ 0xe8 tk_dim equ 0xe9 tk_rem equ 0xea tk_for equ 0xeb tk_go_to equ 0xec tk_go_sub equ 0xed tk_input equ 0xee tk_load equ 0xef tk_list equ 0xf0 tk_let equ 0xf1 tk_pause equ 0xf2 tk_next equ 0xf3 tk_poke equ 0xf4 tk_print equ 0xf5 tk_plot equ 0xf6 tk_run equ 0xf7 tk_save equ 0xf8 tk_randomize equ 0xf9 tk_if equ 0xfa tk_cls equ 0xfb tk_draw equ 0xfc tk_clear equ 0xfd tk_return equ 0xfe tk_copy equ 0xff ;i/o ports printer equ 0xfb ula equ 0xfe ;restarts start equ 0xc7 error equ 0xcf print_a equ 0xd7 get_char equ 0xdf next_char equ 0xe7 ;calc equ 0xef bc_spaces equ 0xf7 mask_int equ 0xff ;command classes no_f_ops equ 0x00 var_rqd equ 0x01 expr_num_str equ 0x02 num_exp_0 equ 0x03 chr_var equ 0x04 var_syn equ 0x05 num_exp equ 0x06 col_offst equ 0x07 two_c_s_num equ 0x08 two_csn_col equ 0x09 str_exp equ 0x0a tap_offst equ 0x0b ;errors ok equ 0xff next_without_for equ 0x00 variable_not_found equ 0x01 subscript_wrong equ 0x02 out_of_memory equ 0x03 out_of_screen equ 0x04 number_too_big equ 0x05 return_without_gosub equ 0x06 end_of_file equ 0x07 stop_statement equ 0x08 invalid_argument equ 0x09 integer_out_of_range equ 0x0a nonsense_in_basic equ 0x0b break_cont_repeats equ 0x0c out_of_data equ 0x0d invalid_file_name equ 0x0e no_room_for_line equ 0x0f stop_in_input equ 0x10 for_without_next equ 0x11 invalid_io_device equ 0x12 invalid_colour equ 0x13 break_into_program equ 0x14 ramtop_no_good equ 0x15 statement_lost equ 0x16 invalid_stream equ 0x17 fn_without_def equ 0x18 parameter_error equ 0x19 tape_loading_error equ 0x1a ;system variables bitmap equ 0x4000 attrmap equ 0x5800 prt_buff equ 0x5b00 kstate equ 0x5c00 ; (iy - 0x3a) kstate_4 equ kstate + 4 ; (iy - 0x36) last_k equ kstate + 8 ; (iy - 0x32) repdel equ last_k + 1 ; (iy - 0x31) repper equ repdel + 1 ; (iy - 0x30) defadd equ repper + 1 ; (iy - 0x2f) defadd_h equ defadd + 1 ; (iy - 0x2e) k_data equ defadd + 2 ; (iy - 0x2d) vdu_data equ k_data + 1 ; (iy - 0x2c) vdu_data_h equ vdu_data + 1 ; (iy - 0x2b) strms equ vdu_data + 2 ; (iy - 0x2a) strms_fe equ strms + 2 ; (iy - 0x28) strms_ff equ strms + 4 ; (iy - 0x26) strms_00 equ strms + 6 ; (iy - 0x24) strms_01 equ strms + 8 ; (iy - 0x22) strms_02 equ strms + 10 ; (iy - 0x20) strms_03 equ strms + 12 ; (iy - 0x1e) strms_04 equ strms + 14 ; (iy - 0x1c) strms_05 equ strms + 16 ; (iy - 0x1a) strms_06 equ strms + 18 ; (iy - 0x18) strms_07 equ strms + 20 ; (iy - 0x16) strms_08 equ strms + 22 ; (iy - 0x14) strms_09 equ strms + 24 ; (iy - 0x12) strms_10 equ strms + 26 ; (iy - 0x10) strms_11 equ strms + 28 ; (iy - 0x0e) strms_12 equ strms + 30 ; (iy - 0x0c) strms_13 equ strms + 32 ; (iy - 0x0a) strms_14 equ strms + 34 ; (iy - 0x08) strms_15 equ strms + 36 ; (iy - 0x06) chars equ strms + 38 ; (iy - 0x04) rasp equ chars + 2 ; (iy - 0x02) pip equ rasp + 1 ; (iy - 0x01) err_nr equ pip + 1 ; (iy + 0x00) flags equ err_nr + 1 ; (iy + 0x01) vdu_flag equ flags + 1 ; (iy + 0x02) err_sp equ vdu_flag + 1 ; (iy + 0x03) list_sp equ err_sp + 2 ; (iy + 0x05) mode equ list_sp + 2 ; (iy + 0x07) newppc equ mode + 1 ; (iy + 0x08) nsppc equ newppc + 2 ; (iy + 0x0a) ppc equ nsppc + 1 ; (iy + 0x0b) subppc equ ppc + 2 ; (iy + 0x0d) bordcr equ subppc + 1 ; (iy + 0x0e) e_ppc equ bordcr + 1 ; (iy + 0x0f) e_ppc_h equ e_ppc + 1 ; (iy + 0x10) vars equ e_ppc + 2 ; (iy + 0x11) dest equ vars + 2 ; (iy + 0x13) chans equ dest + 2 ; (iy + 0x15) curchl equ chans + 2 ; (iy + 0x17) prog equ curchl + 2 ; (iy + 0x19) nxtlin equ prog + 2 ; (iy + 0x1b) datadd equ nxtlin + 2 ; (iy + 0x1d) e_line equ datadd + 2 ; (iy + 0x1f) k_cur equ e_line +2 ; (iy + 0x21) ch_add equ k_cur + 2 ; (iy + 0x23) x_ptr equ ch_add + 2 ; (iy + 0x25) worksp equ x_ptr + 2 ; (iy + 0x27) stkbot equ worksp + 2 ; (iy + 0x29) stkend equ stkbot + 2 ; (iy + 0x2b) stkend_h equ stkend + 1 ; (iy + 0x2c) breg equ stkend + 2 ; (iy + 0x2d) mem equ breg + 1 ; (iy + 0x2e) flags2 equ mem + 2 ; (iy + 0x30) df_sz equ flags2 + 1 ; (iy + 0x31) s_top equ df_sz + 1 ; (iy + 0x32) oldppc equ s_top + 2 ; (iy + 0x34) osppc equ oldppc + 2 ; (iy + 0x36) flagx equ osppc + 1 ; (iy + 0x37) strlen equ flagx + 1 ; (iy + 0x38) t_addr equ strlen + 2 ; (iy + 0x3a) seed equ t_addr + 2 ; (iy + 0x3c) frames equ seed + 2 ; (iy + 0x3e) frames_h equ frames + 2 ; (iy + 0x40) udg equ frames + 3 ; (iy + 0x41) coords equ udg + 2 ; (iy + 0x43) coord_y equ coords + 1 ; (iy + 0x44) p_posn equ coords + 2 ; (iy + 0x45) pr_cc equ p_posn + 1 ; (iy + 0x46) echo_e equ pr_cc + 2 ; (iy + 0x48) df_cc equ echo_e + 2 ; (iy + 0x4a) df_ccl equ df_cc + 2 ; (iy + 0x4c) s_posn equ df_ccl + 2 ; (iy + 0x4e) s_posn_h equ s_posn + 1 ; (iy + 0x4f) sposnl equ s_posn + 2 ; (iy + 0x50) sposnl_h equ sposnl + 1 ; (iy + 0x51) scr_ct equ sposnl + 2 ; (iy + 0x52) attr_p equ scr_ct + 1 ; (iy + 0x53) mask_p equ attr_p + 1 ; (iy + 0x54) attr_t equ mask_p + 1 ; (iy + 0x55) mask_t equ attr_t + 1 ; (iy + 0x56) p_flag equ mask_t + 1 ; (iy + 0x57) membot equ p_flag + 1 ; (iy + 0x58) mem_0_2 equ membot + 2 ; (iy + 0x5a) mem_0_4 equ membot + 4 ; (iy + 0x5c) mem_1 equ membot + 5 ; (iy + 0x5d) mem_1_2 equ membot + 7 ; (iy + 0x5f) mem_2 equ membot + 10 ; (iy + 0x62) mem_2_2 equ membot + 12 ; (iy + 0x64) mem_3 equ membot + 15 ; (iy + 0x67) mem_3_2 equ membot + 17 ; (iy + 0x69) mem_4 equ membot + 20 ; (iy + 0x6c) mem_4_2 equ membot + 22 ; (iy + 0x6e) mem_4_4 equ membot + 24 ; (iy + 0x70) mem_5 equ membot + 25 ; (iy + 0x71) mem_5_1 equ membot + 26 ; (iy + 0x72) nmiadd equ membot + 30 ; (iy + 0x76) ramtop equ nmiadd + 2 ; (iy + 0x78) p_ramt equ ramtop + 2 ; (iy + 0x7a) channels equ p_ramt + 2 ;system variable IY offsets ;negative _kstate equ 0x3a _kstate_4 equ 0x36 _last_k equ 0x32 _repdel equ 0x31 _repper equ 0x30 _defadd equ 0x2f _defadd_h equ 0x2e _k_data equ 0x2d _vdu_data equ 0x2c _vdu_data_h equ 0x2b _strms equ 0x2a _strms_fe equ 0x28 _strms_ff equ 0x26 _strms_00 equ 0x24 _strms_01 equ 0x22 _strms_02 equ 0x20 _strms_03 equ 0x1e _strms_04 equ 0x1c _strms_05 equ 0x1a _strms_06 equ 0x18 _strms_07 equ 0x16 _strms_08 equ 0x14 _strms_09 equ 0x12 _strms_10 equ 0x10 _strms_11 equ 0x0e _strms_12 equ 0x0c _strms_13 equ 0x0a _strms_14 equ 0x08 _strms_15 equ 0x06 _chars equ 0x04 _rasp equ 0x02 _pip equ 0x01 ; positive _err_nr equ 0x00 _flags equ 0x01 _vdu_flag equ 0x02 _err_sp equ 0x03 _list_sp equ 0x05 _mode equ 0x07 _newppc equ 0x08 _nsppc equ 0x0a _ppc equ 0x0b _subppc equ 0x0d _bordcr equ 0x0e _e_ppc equ 0x0f _e_ppc_h equ 0x10 _vars equ 0x11 _dest equ 0x13 _chans equ 0x15 _curchl equ 0x17 _prog equ 0x19 _nxtlin equ 0x1b _datadd equ 0x1d _e_line equ 0x1f _k_cur equ 0x21 _k_cur_h equ 0x22 _ch_add equ 0x23 _x_ptr equ 0x25 _x_ptr_h equ 0x26 _worksp equ 0x27 _stkbot equ 0x29 _stkend equ 0x2b _stkend_h equ 0x2c _breg equ 0x2d _mem equ 0x2e _flags2 equ 0x30 _df_sz equ 0x31 _s_top equ 0x32 _oldppc equ 0x34 _osppc equ 0x36 _flagx equ 0x37 _strlen equ 0x38 _t_addr equ 0x3a _seed equ 0x3c _frames equ 0x3e _frames_h equ 0x40 _udg equ 0x41 _coords equ 0x43 _coord_y equ 0x44 _p_posn equ 0x45 _pr_cc equ 0x46 _echo_e equ 0x48 _df_cc equ 0x4a _df_ccl equ 0x4c _s_posn equ 0x4e _s_posn_h equ 0x4f _sposnl equ 0x50 _sposnl_h equ 0x51 _scr_ct equ 0x52 _attr_p equ 0x53 _mask_p equ 0x54 _attr_t equ 0x55 _mask_t equ 0x56 _p_flag equ 0x57 _membot equ 0x58 _mem_0_2 equ 0x5a _mem_0_4 equ 0x5c _mem_1 equ 0x5d _mem_1_2 equ 0x5f _mem_2 equ 0x62 _mem_2_2 equ 0x64 _mem_3 equ 0x67 _mem_3_2 equ 0x69 _mem_4 equ 0x6c _mem_4_2 equ 0x6e _mem_4_3 equ 0x6f _mem_4_4 equ 0x70 _mem_5 equ 0x71 _mem_5_1 equ 0x72 _nmiadd equ 0x76 _ramtop equ 0x78 _p_ramt equ 0x7a