@@ -5468,8 +5468,19 @@ uint32_t PPC32Emulator::Assembler::asm_mtfsf(const StreamItem& si) {
54685468}
54695469
54705470uint32_t PPC32Emulator::Assembler::asm_data (const StreamItem& si) {
5471- const auto & a = si.check_args ({ArgType::IMMEDIATE});
5472- return a[0 ].value ;
5471+ if (si.args .size () != 1 ) {
5472+ throw std::runtime_error (" incorrect argument count for .data" );
5473+ }
5474+ const auto & arg = si.args [0 ];
5475+ if (arg.type == ArgType::BRANCH_TARGET) {
5476+ if (arg.label_name .empty ()) {
5477+ throw runtime_error (" incorrect argument type for .offsetof" );
5478+ }
5479+ return this ->label_addresses .at (arg.label_name );
5480+ } else {
5481+ si.check_args ({ArgType::IMMEDIATE});
5482+ return arg.value ;
5483+ }
54735484}
54745485
54755486uint32_t PPC32Emulator::Assembler::asm_offsetof (const StreamItem& si) {
@@ -6392,10 +6403,16 @@ void PPC32Emulator::Assembler::assemble(const string& text, function<string(cons
63926403
63936404 if (op_name == " .address" ) {
63946405 const auto & arg = args.at (0 );
6395- if (arg.type != ArgType::IMMEDIATE) {
6406+ if (arg.type == ArgType::BRANCH_TARGET) {
6407+ if (arg.label_name .empty ()) {
6408+ throw std::runtime_error (" incorrect arguemnt type for .address directive" );
6409+ }
6410+ si_address = this ->label_addresses .at (arg.label_name );
6411+ } else if (arg.type == ArgType::IMMEDIATE) {
6412+ si_address = args.at (0 ).value ;
6413+ } else {
63966414 throw runtime_error (" missing or invalid argument to .address directive" );
63976415 }
6398- si_address = args.at (0 ).value ;
63996416 continue ;
64006417 }
64016418 if (op_name == " .label" ) {
0 commit comments