EmbeddedRelated.com
Forums
Memfault Beyond the Launch

IAR Assembler Question

Started by Ray Hurst September 26, 2008
This is a question on the following listing.

I was playing around with how the IAR assembler reacts to various
addressing modes with the MSP430F2274 microprocessor. This has data
space starting at 200h and code space starting at 8000h. I noticed an
unexpected result with the symbolic mode.

24 00000C C056F281 ADD.B R6, EDE <- EDE is at 0x200
25 000010 C056EE01 ADD.B R6, 0x200

When I assembled the above statements I had a significant difference in
the word following the ADD.B instruction. The statement "ADD.B R6, EDE"
(EDE has a value of 200h) resulted in the code C056F281 and the
statement "ADD.B R6, 0x200" results in the code C056EE01. The difference
between the first and second offset word is about 8000h.

Can anybody explain why?
Ray

###############################################################################
#
#
# IAR Systems MSP430 Assembler V4.11B/W32 26/Sep/2008 14:10:01
#
# Copyright 1996-2008 IAR Systems. All rights reserved.
#
#
#
# Target option = MSP430
#
# Source file = C:\Documents and Settings\hurst_r\My
Documents\IAR Embedded Workbench\430\workspace\test\test_symbolic.s43#
# List file = C:\Documents and Settings\hurst_r\My
Documents\IAR Embedded
Workbench\430\workspace\test\Debug\List\test_symbolic.lst#
# Object file = C:\Documents and Settings\hurst_r\My
Documents\IAR Embedded
Workbench\430\workspace\test\Debug\Obj\test_symbolic.r43#
# Command line = C:\Documents and Settings\hurst_r\My
Documents\IAR Embedded Workbench\430\workspace\test\test_symbolic.s43 #
# -OC:\Documents and Settings\hurst_r\My
Documents\IAR Embedded Workbench\430\workspace\test\Debug\Obj\ #
# -s+ -M<> -w+
#
# -LC:\Documents and Settings\hurst_r\My
Documents\IAR Embedded Workbench\430\workspace\test\Debug\List\ #
# -t8 -r -D__MSP430F2274__
#
# -IC:\Program Files\IAR Systems\Embedded
Workbench 5.0\430\INC\ #
#
#
###############################################################################

1 00FFFE #include "msp430.h" ;
#define controlled include file
2 00FFFE
3 00FFFE NAME main
; module
name
4 00FFFE
5 000000 PUBLIC main
; make
the

main

label

vissibl
e
6 00FFFE ;
outside this module
7 00FFFE ORG 0FFFEh
8 00FFFE .... DC16 init
; set
reset vector to 'init'
label
9 010000
10 000000 RSEG DATA16_Z
11 000000 EDE:
12 000000 0200 DW 2
13 000002 TONI:
14 000002 0200 DW 2
15 000004
16 000000 RSEG CSTACK ;
pre-declaration of segment
17 000000 RSEG CODE
; place
program in 'CODE' segment
18 000000
19 000000 3140.... init: MOV #SFE(CSTACK), SP
; set up
stack
20 000004
21 000004 0343 main: NOP
; main

program
22 000006 B240805A2001 MOV.W #WDTPW+WDTHOLD,&WDTCTL
; Stop

watchdo
g

timer
23 00000C
24 00000C C056F281 ADD.B R6, EDE
25 000010 C056EE01 ADD.B R6, 0x200
26 000014
27 000014 FF3F JMP $
; jump
to current location '$'
28 000016 ;
(endless loop)
29 000016 END
##############################
# CRC:7E94 #
# Errors: 0 #
# Warnings: 0 #
# Bytes: 28 #
##############################

Beginning Microcontrollers with the MSP430

I had expected it to be the same as this listing:

###############################################################################
#
#
# IAR Systems MSP430 Assembler V4.11B/W32 27/Sep/2008 15:08:10
#
# Copyright 1996-2008 IAR Systems. All rights reserved.
#
#
#
# Target option = MSP430
#
# Source file = C:\Documents and Settings\Ray Hurst\My
Documents\IAR Embedded Workbench\430\workspace\test\test_symbolic.s43#
# List file = C:\Documents and Settings\Ray Hurst\My
Documents\IAR Embedded
Workbench\430\workspace\test\Debug\List\test_symbolic.lst#
# Object file = C:\Documents and Settings\Ray Hurst\My
Documents\IAR Embedded
Workbench\430\workspace\test\Debug\Obj\test_symbolic.r43#
# Command line = C:\Documents and Settings\Ray Hurst\My
Documents\IAR Embedded Workbench\430\workspace\test\test_symbolic.s43 #
# -OC:\Documents and Settings\Ray Hurst\My
Documents\IAR Embedded Workbench\430\workspace\test\Debug\Obj\ #
# -s+ -M<> -w+
#
# -LC:\Documents and Settings\Ray Hurst\My
Documents\IAR Embedded Workbench\430\workspace\test\Debug\List\ #
# -t8 -r -D__MSP430F2274__
#
# -ID:\Program Files\IAR Systems\Embedded
Workbench 5.0\430\INC\ #
#
#
###############################################################################

1 000200 #include "msp430.h" ;
#define controlled include file
2 000200
3 000200 NAME main
; module
name
4 000200
5 000200 ORG 0x200
6 000200 EDE:
7 000200 0200 DW 2
8 000202 TONI:
9 000202 0200 DW 2
10 000204
11 008000 ORG 08000h
12 008000
13 008000 31400006 init: MOV #0x600, R1
; set up

stack
14 008004
15 008004 0343 main: NOP
; main

program
16 008006 B240805A2001 MOV.W #WDTPW+WDTHOLD,&WDTCTL
; Stop

watchdo
g

timer
17 00800C
18 00800C C056F281 ADD.B R6, EDE
19 008010 C056EE81 ADD.B R6, 0x200
20 008014
21 008014 FF3F JMP $ ;
outside this module
22 008016
23 00FFFE ORG 0FFFEh
24 00FFFE 0080 DC16 init
; set
reset vector to 'init'
label
25 010000
26 010000
27 010000 ;; RSEG CODE ;
place program in 'CODE' segment
28 010000 ; jump to current
location
'$'
29 010000 ;
(endless loop)
30 010000 END
##############################
# CRC:972E #
# Errors: 0 #
# Warnings: 0 #
# Bytes: 28 #
##############################


Memfault Beyond the Launch