@@ -146,6 +146,7 @@ function assemble(files: [string, string][]) {
146146 const globalLabelMap : labelMap = new Map ( ) ;
147147
148148 const asmMap = new Map < number , { file : string ; line : number } > ( ) ;
149+ const badReads : number [ ] = [ ] ;
149150
150151 function link ( labelMap : labelMap , dataLables : linkerInfo , globalRun = false , macro = false ) {
151152 const ram = new Ram ( dataView , textView , [ dataIndex , textIndex , 1 << 22 ] ) ;
@@ -271,6 +272,15 @@ function assemble(files: [string, string][]) {
271272 i = 0 ,
272273 macro = false ,
273274 ) {
275+ function fixBadReads ( ) {
276+ let read = 0 ;
277+ while ( ( read = badReads . pop ( ) || 0 ) ) {
278+ asmMap . set ( read , {
279+ file,
280+ line : i ,
281+ } ) ;
282+ }
283+ }
274284 console . trace ( "test" ) ;
275285 let macroBuild : macro | undefined ;
276286 function placeData (
@@ -295,10 +305,13 @@ function assemble(files: [string, string][]) {
295305 file ,
296306 ) ;
297307 }
298- asmMap . set ( place === "text" ? textIndex + 0x00400000 : dataIndex + 0x10010000 , {
299- file,
300- line : i ,
301- } ) ;
308+ if ( isNaN ( i ) )
309+ badReads . push ( place === "text" ? textIndex + 0x00400000 : dataIndex + 0x10010000 ) ;
310+ else
311+ asmMap . set ( place === "text" ? textIndex + 0x00400000 : dataIndex + 0x10010000 , {
312+ file,
313+ line : i ,
314+ } ) ;
302315 if ( ( directive === "ascii" || directive === "asciz" ) && place === "data" ) {
303316 if ( data . type !== "string" ) {
304317 throw new AssemblError ( I18n . errors . notAString ( i + 1 + "" , data . type ) , i , file ) ;
@@ -1017,6 +1030,7 @@ function assemble(files: [string, string][]) {
10171030 macro . line ,
10181031 true ,
10191032 ) ;
1033+ fixBadReads ( ) ;
10201034 for ( const thing of dataLables2 ) {
10211035 dataLables . set ( ...thing ) ;
10221036 }
@@ -1150,6 +1164,7 @@ function assemble(files: [string, string][]) {
11501164 macro . line ,
11511165 true ,
11521166 ) ;
1167+ fixBadReads ( ) ;
11531168 } catch ( e ) {
11541169 if ( e instanceof AssemblError ) {
11551170 e . addTrace ( i , file ) ;
0 commit comments