@@ -52,7 +52,7 @@ static void emit_inline_thumb_end_pass(emit_inline_asm_t *emit) {
5252
5353static int emit_inline_thumb_count_params (emit_inline_asm_t * emit , int n_params , py_parse_node_t * pn_params ) {
5454 if (n_params > 4 ) {
55- printf ("SyntaxError: can only have up to 3 parameters to inline assembler \n" );
55+ printf ("SyntaxError: can only have up to 4 parameters to inline thumb assembly \n" );
5656 return 0 ;
5757 }
5858 for (int i = 0 ; i < n_params ; i ++ ) {
@@ -62,7 +62,7 @@ static int emit_inline_thumb_count_params(emit_inline_asm_t *emit, int n_params,
6262 }
6363 const char * p = qstr_str (PY_PARSE_NODE_LEAF_ARG (pn_params [i ]));
6464 if (!(strlen (p ) == 2 && p [0 ] == 'r' && p [1 ] == '0' + i )) {
65- printf ("SyntaxError: parameter %d to inline assembler must be r%d\n" , i , i );
65+ printf ("SyntaxError: parameter %d to inline assembler must be r%d\n" , i + 1 , i );
6666 return 0 ;
6767 }
6868 }
@@ -128,14 +128,24 @@ static int get_arg_label(emit_inline_asm_t *emit, qstr op, py_parse_node_t *pn_a
128128
129129static void emit_inline_thumb_op (emit_inline_asm_t * emit , qstr op , int n_args , py_parse_node_t * pn_args ) {
130130 // TODO perhaps make two tables:
131+ // one_args =
132+ // "b", LAB, asm_thumb_b_n,
133+ // "bgt", LAB, asm_thumb_bgt_n,
131134 // two_args =
132135 // "movs", RLO, I8, asm_thumb_movs_reg_i8
133136 // "movw", REG, REG, asm_thumb_movw_reg_i16
134137 // three_args =
135138 // "subs", RLO, RLO, I3, asm_thumb_subs_reg_reg_i3
136139
137140 // 1 arg
138- if (strcmp (qstr_str (op ), "bgt" ) == 0 ) {
141+ if (strcmp (qstr_str (op ), "b" ) == 0 ) {
142+ if (!check_n_arg (op , n_args , 1 )) {
143+ return ;
144+ }
145+ int label_num = get_arg_label (emit , op , pn_args , 0 );
146+ // TODO check that this succeeded, ie branch was within range
147+ asm_thumb_b_n (emit -> as , label_num );
148+ } else if (strcmp (qstr_str (op ), "bgt" ) == 0 ) {
139149 if (!check_n_arg (op , n_args , 1 )) {
140150 return ;
141151 }
0 commit comments