mirror of
https://github.com/raspberrypi/pico-sdk.git
synced 2025-12-10 07:14:36 +01:00
Merge a7708c7a5f into a76f2416ba
This commit is contained in:
commit
01114cc409
5 changed files with 33 additions and 5 deletions
|
|
@ -220,6 +220,8 @@ output_fmt [^%\n]+
|
||||||
|
|
||||||
{comment} { }
|
{comment} { }
|
||||||
|
|
||||||
|
"." return yy::parser::make_DOT(loc);
|
||||||
|
|
||||||
. { throw yy::parser::syntax_error(loc, "invalid character: " + std::string(yytext)); }
|
. { throw yy::parser::syntax_error(loc, "invalid character: " + std::string(yytext)); }
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@
|
||||||
DOT_SET ".set"
|
DOT_SET ".set"
|
||||||
DOT_OUT ".out"
|
DOT_OUT ".out"
|
||||||
DOT_IN ".in"
|
DOT_IN ".in"
|
||||||
|
DOT "."
|
||||||
|
|
||||||
JMP "jmp"
|
JMP "jmp"
|
||||||
WAIT "wait"
|
WAIT "wait"
|
||||||
|
|
@ -203,8 +204,8 @@ directive:
|
||||||
| DOT_OUT value direction autop threshold { pioasm.get_current_program(@1, ".out", true).set_out(@$, $2, $3, $4, $5); }
|
| DOT_OUT value direction autop threshold { pioasm.get_current_program(@1, ".out", true).set_out(@$, $2, $3, $4, $5); }
|
||||||
| DOT_SET value { pioasm.get_current_program(@1, ".set", true).set_set_count(@$, $2); }
|
| DOT_SET value { pioasm.get_current_program(@1, ".set", true).set_set_count(@$, $2); }
|
||||||
| WRAP_TARGET { pioasm.get_current_program(@1, ".wrap_target").set_wrap_target(@$); }
|
| WRAP_TARGET { pioasm.get_current_program(@1, ".wrap_target").set_wrap_target(@$); }
|
||||||
|
| WRAP expression { pioasm.get_current_program(@1, ".wrap").set_wrap(@$, $2); }
|
||||||
| WRAP { pioasm.get_current_program(@1, ".wrap").set_wrap(@$); }
|
| WRAP { pioasm.get_current_program(@1, ".wrap").set_wrap(@$); }
|
||||||
| WORD value { pioasm.get_current_program(@1, "instruction").add_instruction(std::shared_ptr<instruction>(new instr_word(@$, $2))); }
|
|
||||||
| LANG_OPT NON_WS NON_WS ASSIGN INT { pioasm.get_current_program(@1, ".lang_opt").add_lang_opt($2, $3, std::to_string($5)); }
|
| LANG_OPT NON_WS NON_WS ASSIGN INT { pioasm.get_current_program(@1, ".lang_opt").add_lang_opt($2, $3, std::to_string($5)); }
|
||||||
| LANG_OPT NON_WS NON_WS ASSIGN STRING { pioasm.get_current_program(@1, ".lang_opt").add_lang_opt($2, $3, $5); }
|
| LANG_OPT NON_WS NON_WS ASSIGN STRING { pioasm.get_current_program(@1, ".lang_opt").add_lang_opt($2, $3, $5); }
|
||||||
| LANG_OPT NON_WS NON_WS ASSIGN NON_WS { pioasm.get_current_program(@1, ".lang_opt").add_lang_opt($2, $3, $5); }
|
| LANG_OPT NON_WS NON_WS ASSIGN NON_WS { pioasm.get_current_program(@1, ".lang_opt").add_lang_opt($2, $3, $5); }
|
||||||
|
|
@ -224,6 +225,7 @@ directive:
|
||||||
/* value is a more limited top level expression... requiring parenthesis */
|
/* value is a more limited top level expression... requiring parenthesis */
|
||||||
%type <std::shared_ptr<resolvable>> value;
|
%type <std::shared_ptr<resolvable>> value;
|
||||||
value: INT { $$ = resolvable_int(@$, $1); }
|
value: INT { $$ = resolvable_int(@$, $1); }
|
||||||
|
| DOT { $$ = resolvable_int(@$, pioasm.get_current_program(@1, ".").instructions.size()); }
|
||||||
| ID { $$ = std::shared_ptr<resolvable>(new name_ref(@$, $1)); }
|
| ID { $$ = std::shared_ptr<resolvable>(new name_ref(@$, $1)); }
|
||||||
| LPAREN expression RPAREN { $$ = $2; }
|
| LPAREN expression RPAREN { $$ = $2; }
|
||||||
|
|
||||||
|
|
@ -257,7 +259,8 @@ instruction:
|
||||||
|
|
||||||
%type <std::shared_ptr<instruction>> base_instruction;
|
%type <std::shared_ptr<instruction>> base_instruction;
|
||||||
base_instruction:
|
base_instruction:
|
||||||
NOP { $$ = std::shared_ptr<instruction>(new instr_nop(@$)); }
|
WORD value { $$ = std::shared_ptr<instruction>(new instr_word(@$, $2)); }
|
||||||
|
| NOP { $$ = std::shared_ptr<instruction>(new instr_nop(@$)); }
|
||||||
| JMP condition comma expression { $$ = std::shared_ptr<instruction>(new instr_jmp(@$, $2, $4)); }
|
| JMP condition comma expression { $$ = std::shared_ptr<instruction>(new instr_jmp(@$, $2, $4)); }
|
||||||
| WAIT value wait_source { $$ = std::shared_ptr<instruction>(new instr_wait(@$, $2, $3)); }
|
| WAIT value wait_source { $$ = std::shared_ptr<instruction>(new instr_wait(@$, $2, $3)); }
|
||||||
| WAIT wait_source { $$ = std::shared_ptr<instruction>(new instr_wait(@$, resolvable_int(@$, 1), $2)); }
|
| WAIT wait_source { $$ = std::shared_ptr<instruction>(new instr_wait(@$, resolvable_int(@$, 1), $2)); }
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,17 @@ void program::set_wrap(const yy::location &l) {
|
||||||
wrap = resolvable_int(l, instructions.size() - 1);
|
wrap = resolvable_int(l, instructions.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void program::set_wrap(const yy::location &l, rvalue target) {
|
||||||
|
set_wrap(l);
|
||||||
|
|
||||||
|
if (wrap_target) {
|
||||||
|
std::stringstream msg;
|
||||||
|
msg << ".wrap_target was already specified at " << wrap_target->location;
|
||||||
|
throw syntax_error(l, msg.str());
|
||||||
|
}
|
||||||
|
wrap_target = std::move(target);
|
||||||
|
}
|
||||||
|
|
||||||
void program::set_wrap_target(const yy::location &l) {
|
void program::set_wrap_target(const yy::location &l) {
|
||||||
if (wrap_target) {
|
if (wrap_target) {
|
||||||
std::stringstream msg;
|
std::stringstream msg;
|
||||||
|
|
@ -299,12 +310,12 @@ raw_encoding instruction::raw_encode(program& program) {
|
||||||
throw syntax_error(location, "internal error");
|
throw syntax_error(location, "internal error");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint instr_word::encode(program &program) {
|
raw_encoding instr_word::raw_encode(program& program) {
|
||||||
uint value = encoding->resolve(program);
|
uint value = encoding->resolve(program);
|
||||||
if (value > 0xffffu) {
|
if (value > 0xffffu) {
|
||||||
throw syntax_error(location, ".word value must be a positive 16 bit value");
|
throw syntax_error(location, ".word value must be a positive 16 bit value");
|
||||||
}
|
}
|
||||||
return value;
|
return {inst_type(0), value >> 5, value & 0x1fu};
|
||||||
}
|
}
|
||||||
|
|
||||||
uint instr_mov::get_push_get_index(const program &program, extended_mov index) {
|
uint instr_mov::get_push_get_index(const program &program, extended_mov index) {
|
||||||
|
|
|
||||||
|
|
@ -321,6 +321,8 @@ struct program : public src_item {
|
||||||
|
|
||||||
void set_wrap(const yy::location &l);
|
void set_wrap(const yy::location &l);
|
||||||
|
|
||||||
|
void set_wrap(const yy::location &l, rvalue target);
|
||||||
|
|
||||||
void set_sideset(const yy::location &l, rvalue _sideset, bool optional, bool pindirs) {
|
void set_sideset(const yy::location &l, rvalue _sideset, bool optional, bool pindirs) {
|
||||||
sideset = rvalue_loc(_sideset, l);
|
sideset = rvalue_loc(_sideset, l);
|
||||||
sideset_opt = optional;
|
sideset_opt = optional;
|
||||||
|
|
@ -486,7 +488,7 @@ struct instr_word : public instruction {
|
||||||
|
|
||||||
instr_word(const yy::location &l, rvalue encoding) : instruction(l), encoding(std::move(encoding)) {}
|
instr_word(const yy::location &l, rvalue encoding) : instruction(l), encoding(std::move(encoding)) {}
|
||||||
|
|
||||||
uint encode(program &program) override;
|
raw_encoding raw_encode(program &program) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,16 @@ wait gpio 40
|
||||||
.mov_status txfifo < 12
|
.mov_status txfifo < 12
|
||||||
.mov_status irq next set 3
|
.mov_status irq next set 3
|
||||||
|
|
||||||
|
.program wrap
|
||||||
|
decrement:
|
||||||
|
jmp x--, .+1
|
||||||
|
skip:
|
||||||
|
.wrap .+1
|
||||||
|
delay:
|
||||||
|
jmp x--, .
|
||||||
|
jump:
|
||||||
|
.word (.-1) [2]
|
||||||
|
|
||||||
.program python
|
.program python
|
||||||
.pio_version 1
|
.pio_version 1
|
||||||
wait 0 jmppin
|
wait 0 jmppin
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue