This problem is no longer an issue. See this post
I probably should have investigated this problem some more across different compilers, but that list.html file had me going. Anyway. The old post stays to show what I thought was a problem, and its solution.

Known to affect Brass 1.0.5.3

While coding a semi-secret project, I ran into an issue with Brass involving the .relocate directive. On second (and presumably further) use of the .relocate directive, the addresses within are incorrectly modified.

The list.html file indicates that it should have been correctly assembled, but the information provided by the .echoln directives scattered throughout the code says otherwise, and the app that is generated and inspected under an emulator's debugger matches what the console window says.

The batch script I use to build this is as follows:

Code:
@echo off
%cd%\brass -e -d %cd%\test.asm %cd%\test.8xk -l list.html
pause


The code that demonstrates this problem is as follows:

Code:
.binarymode ti8xapp
.variablename "TeSTAPP"
.include "ti83plus.inc"
.deflong bjump(label)
   call bRT_JUMP0
   .dw label
.enddeflong

.deflong bcall(label)
   rst rBR_CALL
   .dw label
.enddeflong

.defpage 0,16*1024,$4000

.page 0
.block 128

 di
 jr $  ;halts app to allow inspection
 bjump(_JForceCmdNoChar)

 jp JUMP_1
 jp JUMP_2
 nop
 nop

rollingVariable = $9D95
.echoln "ROLLING VAR TAKE 1:",rollingVariable

JUMP_1_BASE:
.relocate rollingVariable
JUMP_1_START:
JUMP_1:
 ld hl,0
-:
 dec hl
 ld a,h
 or L
 jr nz,{-}
 ret
JUMP_1_END:
.endrelocate

rollingVariable = rollingVariable + (JUMP_1_END-JUMP_1_START)
.echoln "ROLLING VAR TAKE 2:",rollingVariable
.echoln $

JUMP_2_BASE:
.relocate rollingVariable
JUMP_2_START:
JUMP_2
 ld hl,0
 ld (currow),hl
 ld hl,JUMP_2_LABEL
 bcall(_PutC)
 ret
JUMP_2_LABEL:
.db "HELLO WORLD",0
JUMP_2_END:
.endrelocate

rollingVariable = rollingVariable + (JUMP_2_END-JUMP_2_START)
.echoln "ROLLING VAR TAKE 3:",rollingVariable
.echoln "JUMP_1_BASE:",JUMP_1_BASE," JUMP_1_START:",JUMP_1_START," JUMP_1_END:",JUMP_1_END
.echoln "JUMP_2_BASE:",JUMP_2_BASE," JUMP_2_START:",JUMP_2_START," JUMP_2_END:",JUMP_2_END


.end

Code:
.binarymode ti8xapp
.variablename "TeSTAPP"
.include "ti83plus.inc"
.deflong bjump(label)
   call bRT_JUMP0
   .dw label
.enddeflong

.deflong bcall(label)
   rst rBR_CALL
   .dw label
.enddeflong

.defpage 0,16*1024,$4000

.page 0
.block 128

 di
 jr $  ;halts app to allow inspection
 bjump(_JForceCmdNoChar)

 jp JUMP_1
 jp JUMP_2
 nop
 nop

rollingVariable = $9D95
.echoln "ROLLING VAR TAKE 1:",rollingVariable

JUMP_1_BASE:
.relocate rollingVariable
JUMP_1_START:
JUMP_1:
 ld hl,0
-:
 dec hl
 ld a,h
 or L
 jr nz,{-}
 ret
JUMP_1_END:
.endrelocate

rollingVariable2 = rollingVariable + (JUMP_1_END-JUMP_1_START)
.echoln "ROLLING VAR TAKE 2:",rollingVariable2
.echoln $

JUMP_2_BASE:
.relocate rollingVariable2
JUMP_2_START:
JUMP_2
 ld hl,0
 ld (currow),hl
 ld hl,JUMP_2_LABEL
 bcall(_PutC)
 ret
JUMP_2_LABEL:
.db "HELLO WORLD",0
JUMP_2_END:
.endrelocate

rollingVariable3 = rollingVariable2 + (JUMP_2_END-JUMP_2_START)
.echoln "ROLLING VAR TAKE 3:",rollingVariable3
.echoln "JUMP_1_BASE:",JUMP_1_BASE," JUMP_1_START:",JUMP_1_START," JUMP_1_END:",JUMP_1_END
.echoln "JUMP_2_BASE:",JUMP_2_BASE," JUMP_2_START:",JUMP_2_START," JUMP_2_END:",JUMP_2_END


.end


This seems to fix it the problem seems to be with redefining a variable.
I guess the problem itself wasn't in the .relocate as I had thought. I should have investigated this a bit more since similar problems was occurring in SPASM. The fix? Define a temporary variable before overwriting one you're still using. Who'd have thought that would make a difference?

Old:

Code:
rollingVariable = rollingVariable + (JUMP_1_END-JUMP_1_START)

New:

Code:
tmp1 = rollingVariable + (JUMP_2_END-JUMP_2_START)
rollingVariable =  tmp1
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement