Sei sulla pagina 1di 8

PRESERVE8

THUMB

AREA RESET,DATA, READONLY
EXPORT __Vectors


__Vectors
DCD 0x20001000
DCD Reset_Handler

ALIGN


AREA MYCODE,CODE,READONLY

ENTRY
EXPORT Reset_Handler

Reset_Handler
;Question#1
;MOV R1, #0x37AF


;Question#2
;MOV R3, #0x5A62
;MOVT R3, #0x0039


;Question#3
;MOV R3, #-321


;Question#4
;MOV R0, #0xA642


;question#5

;Unsigned -458 equal 0xFFFFFE36 in hex.

;MOV R1, #0xFE36 ; Moves 0xFE36 to lower portion of R1
;MOVT R1, #0xFFFF ; Moves 0xFFFF to higher portion of R1
;MOV R2, #0x1CA ; Moves unsigned 458 to R2


;Question#6
;Keeping in mind the fact that for A 16-Bit negative number,
;The upper 16 Bits are already 1(FFFF),when shifted from left,
;The MSB is replaced by (THE MSB-1) Bit which is already 1
;So the number remain signed.


;Question#7
;MOV R0, #0x000D
;MOVT R0, #0x7000


;Question#8
;MOV R0, #0x5AF2
;MOVT R0, #0x000C


;Question#9
;MOV R0, #0x5AF2
;MOVT R0, #0xFFFC


;Question#10
;MOV R1, #0xA964


;Question#11
;MOV R5, #0x1C8B
;MOVT R5, #0xD29D


;Question#12
;MOV R3, #0x1FC3
;MOVT R3, #0x568A


;Question#13
;MOV R5, 0x65FF


;Question#14
;MOV R6, #0x3210
;MOVT R6, #0x7654

STOP

;Question#1
;LSR R2,R1,#1 ;R2=0x1BD7
;LSR R2,R1,#3 ;R2=0x06F5
;LSR R2,R1,#12 ;R2=0x0003


;Question#2
;ASR R4, R3, #1 ;R4=0x001CAD31
;ASR R4, R3, #5 ;R4=0x0001CAD3
;ASR R4, R3, #15 ;R4=0x0072


;Question#3
;LSR R4, R3, #1 ;R4=0x7FFFFF5F
;ASR R5, R3, #1 ;R5=0xFFFFFF5F
;ASR gives correct answer because in LSR a 0 is appended which changes the MSB
,making it 0 instead of 1 ,wheras ASR retains the MSB and the number is still a negative number.


;Question#4
;LSL R2 , R0, #3 ;R2=0x00053210


;Question#5

;LSL R3, R1, #1 ; Logical Shift Left on R1
; R3 value goes to 0xFFFFFC6C
; LSL R3, R2, #1 ; Logical Shift Left on R2
; R3 value goes to 0x00000394
;Question#7
;LSL R5, R0, #2 ;R5=0xC00000034
;LSR R6 , R5, #2 ;R6=0x30000000D
;NET RESULT=THE FIRST TWO BITS i.e MSB AND (MSB-1) bit is lost
;and gets replaced by 00(if not 00 already)


;Question#8
;LSL R4, R0, #0 ;R4=0xC5AF2


;Question#9
;LSL R4, R0, #3 ;R4=0xFFE2D790


;Question#10
;LSR R2, R1, #1 ;R2=0x54B2 ---R1 is shifted to right and got divided by 2.
;ASR R3, R1, #1 ;R3=0x54B2---Same as before..ASR and LSR are same for postive
numbers.
;LSL R4, R1, #1 ;R4=0x000152C8---Shifted to left and got multiplied by 2.
;ROR R5, R1, #1 ;R5=0x54B2---The number is rotated to right and no bit is lost.
;RRX R6, R1 ;R6=0x54B2---Same result as was for ROR


;Question#11
;LSRS R1, R5, #1 ;R1=0x694E8E45,,C=1-- The number moves to right such that LSB is
moved
;TO CARRY AND a '0' Is appended at the first(MSB SIDE).
;ASRS R2, R5, #1 ;R2=0xE94E8E45,,C=1.--The whole number except the MSB
;Is shifted to right and the MSB is retained.
;LSLS R3, R5, #1 ;R3=0xA53A3916,,C=1---The whole number moves to left such that the
MSB
;Is xopied to the carry flag and a 0 is appended at the
end.
;RORS R4, R5, #1 ; R4=0xE94E8E45,,C=1---The number is rotated such tha LSB moves to
MSB and
;Is copied to carry flag as well.
;RRXS R6, R5 ;R6=0x694E8E45,,C=1---The number is treated as A 33 bit number
;By including the carry bit as LSB and then it is rotated
such that carry moves to MSB Aand LSB moves to carry flag.


;Question#12
;ROR R4, R3, #20 ;R4=A1FC3568


;Question#13
;ROR R6, R5, #16 ;R6=0x65FF0000


;Question#14
;ROR R7, R6, #16 ;R7=0x32107654


;Question#16
;RRX R8, R6 ;R8=0x3B2A1908


B STOP
END

Potrebbero piacerti anche