This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

no message about A14 error generated

hi,

next example is compiled without errors but produces wrong results due debug.

;------------------------------------------------------------
; Test program about bug of relocatable calculations
;------------------------------------------------------------
; allocate buffer in XDATA
?XD?BUFFER	SEGMENT	XDATA
		RSEG	?XD?BUFFER
BUFFER:		DS	512	; here may be any number

;------------------------------------------------------------
; Main program
?PR?MAIN	SEGMENT CODE
		RSEG	?PR?MAIN
; load high byte of the buffer address +1 into accumulator
	MOV	A,#(HIGH(BUFFER)+1)
; !!! accumulator contains high byte without +1 !!!

	MOV	A,#(HIGH(BUFFER+256*1))
; here we obtain the correct result

	JMP	$

	END

I know source of the problem but I have no idea why no error about "INVALID RELOCATABLE EXPRESSION" is generated?

Thanks,
Oleg

Parents
  • Unfortunately, HIGH and LOW are not like functions you can use in your assembler code.

    They are instead like expression-wide modifiers that change the byte the assembler/linker view for purposes of instruction construction.

    For example, all of the following expressions using HIGH are evaluated to the same result:

    high buffer + 1
    1 + high buffer
    high(buffer) + 1
    

    The reason is that when the expression is calculated, the HIGH keyword simply sets flag. The expression is calculated (ignoring the HIGH keyword). And, HIGH is applied to the result. The same is true for the LOW and other byte-specific keywords.

    So, if you want to adjust the high byte, you must do something like...

    high buffer+256
    

    Jon

Reply
  • Unfortunately, HIGH and LOW are not like functions you can use in your assembler code.

    They are instead like expression-wide modifiers that change the byte the assembler/linker view for purposes of instruction construction.

    For example, all of the following expressions using HIGH are evaluated to the same result:

    high buffer + 1
    1 + high buffer
    high(buffer) + 1
    

    The reason is that when the expression is calculated, the HIGH keyword simply sets flag. The expression is calculated (ignoring the HIGH keyword). And, HIGH is applied to the result. The same is true for the LOW and other byte-specific keywords.

    So, if you want to adjust the high byte, you must do something like...

    high buffer+256
    

    Jon

Children
No data