From: ian Date: Sun, 1 May 2005 15:11:55 +0000 (+0000) Subject: test harness monitor thingum X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=c163d2c7e0602d1e1c204b665b3bcde9eeda15fd;p=trains.git test harness monitor thingum --- diff --git a/iwjpictest/harness.asm b/iwjpictest/harness.asm index 90b8504..1b97e6d 100644 --- a/iwjpictest/harness.asm +++ b/iwjpictest/harness.asm @@ -5,45 +5,114 @@ ; ; state kept ; E current entry -; A current address +; R current address for reading (Al = low byte; Ah = high_nybble) +; S current address for setting (Bl = low byte; Ah = high_nybble) +; T top address nybble for next address set +; B bitmask for bit operations +; F flags: flag name weight in FT +; printset 0x80 print every value we write into *S ; -; prompt is `>' +; prompt is NL CR > SPC initially, then SPC after each command ; ; data entry -; 0-9a-f hex digit E := E<<4 | (digit value) +; 0-9a-f hex digit E := (E & 0x0f)<<4 | (digit value) +; = confirm value print "=", E +; & set bitmask B := E; print "&", B +; +; address operations +; . set setting address (low byte) S := TE; print R, ",", S +; , set reading address (low byte) R := TE; print R, ",", S +; ' set top address nybble T := E & 0x0f +; ` set flags F := E; print "`", F +; @ confirm addresses and bitmask print R, ",", S, "&", B +; ~ confirm flags and high nybble print "`", F, "'", T ; ; byte operations -; CR enter address A := E -; = confirm value print E -; @ confirm address print A -; ? read and display print *A -; ! set whole byte *A := E +; SPC read and display print *R +; RET, NL set whole byte printset "S", (*S := E) +; TAB read from setting address print "s", *S +; ; bitwise operations -; SPC read and mask print (*A & E) -; + bitwise or (set bits) *A := *A | E -; - bitwise and-not (clear bits) *A := *A & ~E -; ^ bitwise xor (toggle bits) *A := *A ^ E +; ? read and mask print "?", (*R & B) +; _ read and mask from setting addr printset "_", (*S & B) +; + bitwise or (set bits) printset "+", (*S := *S | B) +; - bitwise and-not (clear bits) printset "-", (*S := *S & ~B) +; ^ bitwise xor (toggle bits) printset "^", (*S := *S ^ B) +; +; `printset' means print if `printset' flag is set, otherwise just evaluate + nolist include /usr/share/gputils/header/p18f458.inc include insn-aliases.inc +; list radix dec -e equ 0x70 -a equ FSR1L -star_a equ INDF1 -hex_temp equ 0x72 +;------------------------------------------------------------ +; variable declarations and RAM memory map + +r equ FSR0L +rh equ FSR0H +star_r equ INDF0 + +s equ FSR1L +sh equ FSR1H +star_s equ INDF1 + +perpicled_bit equ 2 + +e equ 0x30 +t equ 0x31 +b equ 0x32 +f equ 0x33 + +hex_temp equ 0x38 +original_op equ 0x39 +value_temp equ 0x3a + +f_printset_bit equ 7 + +test_loc_a5 equ 0x40 +test_loc_5a equ 0x42 + +;---------------------------------------- +serial_literal macro char +; transmits char through the serial port +; W undefined undefined + mov_lw char + rcall serial_write_char + endm code start rcall led_green rcall serial_setup - set_f FSR1H + + clr_f e + mov_lw 0x80 ; PORTA + mov_wf r + set_f rh + mov_wf s + set_f sh + set_f t + mov_lw (1<' + command_loop - mov_lw '>' - rcall serial_write_char + serial_literal ' ' rcall serial_read_char + mov_wf original_op + check_last set 0 checkequal macro value, label add_lw check_last-value @@ -57,16 +126,27 @@ checkatleast macro minvalue, label ; if it takes, W gets char-minvalue check_last set minvalue endm - checkequal 10, command_return - checkequal 13, command_return - checkequal '=', command_confirm_entry - checkequal '@', command_confirm_address - checkequal '?', command_byte_read - checkequal '!', command_byte_write - checkequal ' ', command_bitwise_read_mask - checkequal '+', command_bitwise_or - checkequal '-', command_bitwise_and_not - checkequal '^', command_bitwise_xor + ; data entry + checkequal '=', command_byte_confirm + checkequal '&', command_byte_bitmask_set + ; address operations + checkequal '.', command_address_set_setting + checkequal ',', command_address_set_reading + checkequal 39, command_address_set_high + checkequal '`', command_flags_set + checkequal '@', command_address_confirm + checkequal '~', command_confirm_flags_highnyb + ; byte operations + checkequal ' ', command_byte_read + checkequal 10, command_byte_set + checkequal 13, command_byte_set + checkequal 9, command_byte_read_fromset + ; bit operations + checkequal '?', command_bitwise_read_mask + checkequal '_', command_bitwise_read_mask_fromset + checkequal '+', command_bitwise_or + checkequal '-', command_bitwise_and_not + checkequal '^', command_bitwise_xor checkatleast 'f'+1, command_wrong checkatleast 'a', command_letterhexdigit @@ -79,6 +159,9 @@ command_wrong command_endswitch bra command_loop +;-------------------- +; command digits + command_letterhexdigit add_lw 10 command_digit @@ -89,56 +172,156 @@ command_digit mov_wf e bra command_loop +;-------------------- +; common routines for command loop + +command_endswitch_set + mov_wf star_s + bt_f_if0 f, f_printset_bit + bra command_endswitch_set_ifnot_print + mov_wf value_temp + mov_fw original_op + rcall serial_write_char + mov_fw value_temp command_endswitch_phex rcall serial_write_hex +command_endswitch_set_ifnot_print bra command_endswitch -command_return - mov_ff a,e +;-------------------- +; address commands + +command_address_set_setting + mov_ff t,sh + mov_ff e,s + bra command_address_confirm + +command_address_set_reading + mov_ff t,rh + mov_ff e,r + bra command_address_confirm + +command_address_set_high + mov_ff e,t + bra command_endswitch + +command_flags_set + mov_ff e,f + rcall confirm_flags bra command_endswitch -command_confirm_entry +command_address_confirm + rcall confirm_address + rcall confirm_bitmask + bra command_endswitch + +;---------- +confirm_address +; prints R, ",", S +; W undefined undefined +; hex_temp undefined undefined + mov_fw rh + rcall serial_write_hex_digit + mov_fw r + rcall serial_write_hex + mov_lw ',' + rcall serial_write_char + mov_fw sh + rcall serial_write_hex_digit + mov_fw s + rcall serial_write_hex + bra command_endswitch + +command_confirm_flags_highnyb + rcall confirm_flags + serial_literal 39 + mov_fw t + rcall serial_write_hex_digit + bra command_endswitch + +;---------- +confirm_bitmask +; prints "&", B +; W undefined undefined +; hex_temp undefined undefined + serial_literal '&' + mov_fw b + rcall serial_write_hex + return + +;---------- +confirm_flags +; prints "`", F +; W undefined undefined +; hex_temp undefined undefined + serial_literal '`' + mov_fw f + rcall serial_write_hex + return + +;-------------------- +; byte operations + +command_byte_confirm + serial_literal '=' mov_fw e bra command_endswitch_phex -command_confirm_address - mov_fw a - bra command_endswitch_phex +command_byte_bitmask_set + mov_ff e, b + rcall confirm_bitmask + bra command_endswitch command_byte_read - mov_fw star_a + mov_fw star_r bra command_endswitch_phex -command_byte_write +command_byte_set + mov_lw 'S' + mov_wf original_op mov_fw e - mov_wf star_a - bra command_endswitch + bra command_endswitch_set + +command_byte_read_fromset + serial_literal 's' + mov_fw star_s + bra command_endswitch_phex + +;-------------------- +; bit operations command_bitwise_read_mask + serial_literal '?' mov_fw e - and_wfw star_a + and_wfw star_r + bra command_endswitch_phex + +command_bitwise_read_mask_fromset + serial_literal '_' + mov_fw e + and_wfw star_s bra command_endswitch_phex command_bitwise_or mov_fw e - ior_wff star_a - bra command_endswitch + ior_wfw star_s + bra command_endswitch_set command_bitwise_xor mov_fw e - xor_wff star_a - bra command_endswitch + xor_wfw star_s + bra command_endswitch_set command_bitwise_and_not mov_fw e com_w - and_wff e - bra command_endswitch + and_wfw star_s + bra command_endswitch_set ;---------------------------------------- led_green - bc_f TRISD, 2 ; enable per-pic led output - bs_f LATD, 2 ; set per-pic led output + bc_f TRISD, perpicled_bit + bs_f LATD, perpicled_bit return @@ -146,20 +329,20 @@ led_green serial_setup ; W undefined undefined ; TXSTA undefined } - mov_lw 0x26 ; asynch xmit enabled, high baud rate, 8-bit, - mov_wf TXSTA ; - mov_lw 129 ; 9600bps (with BRGH) - mov_wf SPBRG + mov_lw (1<