# data[].attributes.body
C)
LDI R16,$9F
LDS R16,0x300
LDI R17,$F9
LDS R17,0X301

ADD R16,R17
STS 0x305,R16

D)

# data[].attributes.body
Nik Umar bin Nik Mohamed Nizan
Ray

# data[].attributes.body
C & D

# data[].attributes.body
a.
.CSEG
.ORG 0x100
.EQU store = 0x0500
LDI R21,$34
CBR R21,4
CBR R21,6
STS store, R21

b.
.CSEG
.ORG $200
.def x =R17
.def y =R16
LDI R17, X
MUL R17, 2
ADD R17, 5
MOV R16, R17

# data[].attributes.body
a)
LDI R16, $65
LDI R17, $23
STS $200, R16
STS $201, R17
LDS R16, $200
LDS R17, $201
SUB R16, R17
STS $200, R16

b)
LDI R26, $7F
LDI R27, $F3
LDI R28, $9D
LDI R29, $54
LDI R30, $EA
LDI R31, $4D
SUB R26, R28
SBC R27, R29
ADD R26, R30
ADC R27, R31
STS $400, R26
STS $401, R27

# data[].attributes.body
.CSEG
.ORG 0x200
.EQU SIMPAN = 0X0500

//a
LDI R21,$34
CBR R21, 4
CBR R21, 6
STS SIMPAN, R21

//b
LDI R23, 2
MUL R17, R23
LDI R24, 5
ADD R17,R24
MOV R16,R17

# data[].attributes.body
Part A
SBI DDRA, 3
SBI DDRA, 4
SBI DDRA, 5
LDI R16,0xFF
OUT DDRC,R16

Part B
.cseg
LDI R28,low(TEMP1)
LDI R29,high(TEMP1)
LDI R16,0x45
SWAP R16
ST Y+,R16
LDI R16,0xA4
SWAP R16
ST Y+,R16
LDI R16,0xF3
SWAP R16
ST Y+,R16
LDI R16,0x78
SWAP R16
ST Y+,R16

.DSEG
.org 0x200
TEMP1: .BYTE 1

# data[].attributes.body
b)
.org $200
LDI R20,$3
LDI R21,$5
LDI R22,$7
LDI R23,$2
LDI R17,1 ;R17 IS X
MUL R17,R17 ;x^2
MUL R17,R17 ;x^3
MUL R17,R20   ;3x^3
MOV R15,R17
CLR R17
LDI R17,1 ;R17 IS X
MUL R17,R17 ;x^2
MUL R17,R21   ;5x^2
MOV R14,R17
CLR R17
LDI R17,1 ;R17 IS X
MUL R17,R22   ;7x
ADD R17,R23  ;7X+2
ADD R17,R14
ADD R17,R15
MOV R16,R17

a)
CLR R16
CLR R17
LDI R16,$9F
LDI R17,$F9

STS 0X300,R16
STS 0X301,R17

ADD R16,R17
STS 0X305,R16

# data[].attributes.body
A)
.ORG $100
STS $200, R16
STS $201, R17

LDS R16, $200
LDS R17, $201

SUB R16, R17
STS $200, R16
B)
.ORG $100
LDI R16, $7F
LDI R17, $F3
LDI R18, $9D
LDI R19, $54

SUB R16,R18
SBC R17,R19

LDI R18, $EA
LDI R19, $4D

ADD R16, R18
ADC R17, R19
STS $400, R16
STS $401, R17

# data[].attributes.body
A. .cseg

ldi r10, 0b110100
cbr r10 , 4
cbr r10 , 6
sts 0x0500 , r10

B. .org $200
.def b = r17
.def a = r16

/*main*/

andi b , 2
ldi r18, 0x5
add b , r18
mov a, b

# data[].attributes.body
LDI R16, 0x1C
OUT DDRA, R16
OUT PORTA, R16

LDI R28, 0x00
LDI R29, 0x02
main: LD R17, Y
SWAP R17
ST Y+, R17
RJMP main
.DSEG
.ORG $200

# data[].attributes.body
a) ldi r20,0b00110100
cbr r20,4
cbr r20,6
sts 0x0500,r20

b).ORG0x200
.def x=r17
.de y=r16
mul r17,2
add r17,5
st r16,r17

# data[].attributes.body
A:
.def N=r22

sts 0x200,r19
sts 0x201,r20

lds r21,0x200
lds r22,0x201

sub r21,N
sts 0x200,r21

B)
ldi r16,0x7F
ldi r17,0xF3

ldi r18,0x9D
ldi r19,0x54

ldi r20,0xEA
ldi r21,0x4D

SUB r16,r18
SBC R17,R19
ADD R16,R20
ADC R17,R21

STS 0X400,R16
STS 0X401,R17

# data[].attributes.body
a)

.CESG
.ORG  $200

LDS R16,$400
LDS R17,$401
MUL R16,R17
STS $200,R16

b)

LDI R20,$65
LDI R21,$23
STS $200,R20
STS $201,R21
LDS R22,$200
LDS R23,$201
SUB R22,R23
STS $201,R22

# data[].attributes.body
.CSEG
.ORG 0x200

//a

LDS R16,0x300
LDS R17,0x301
ADD R16,R17
STS 0x305,R16

# data[].attributes.body
a)  LDS R16, 0x400
LDS R17, 0x401
MUL R16, R17
STS 0x200, R16

b)

.ORG 0x200
.DEF 0x200= 1
STS R17, 0x200
LDI R18,3
LDI R19, 4
MUL R17,R18
ADD R17, R19
MOV R16, R17

# data[].attributes.body
a)
Load data from memory address 0x200 and 0x201 which contains hexadecimal numbers of $65 and $23. Subtract the numbers and store the result to memory address 0x200.

.CSEG

	ldi r20, 0X65
	Ldi r21, 0X23

	sts $200, r20
	sts $201, r21

	lds r18, $200
	lds r19, $201

	sub r18, r19
	sts $200, r18

b)
Write an assembly program that will perform 16-bit arithmetic on the following values:

($F37F - $549D) + $4DEA

and place the result at address $401 and $400. (Address $400 should have the lower byte). Determine the contents of address $401 and $400 after the operations are executed.

LDI R20, 0X7F
LDI R21, 0XF3
LDI R22, 0X9D
LDI R23, 0X54
SUB R20, R22
SBC R21, R23
LDI R22, 0XEA
LDI R23, 0X4D
ADD R20, R22
ADC R21, R23
STS $401, R21
STS $400, R20