In: Computer Science
Write a code in arm 8086 keil software version 5 for signed input and perform addition and subtraction using both direct and indirect addressing mode.
Answer.
Using indirect addressing mode.
ADDITION.... CODE..
1 2
3 0000
4 0000
5 0002
6 0004
7 0006
8
9 0000
10
11 0000
12 0000
13 0003
14
15 0005
16 0008
17 000B 8B 04
18 000D 8B 1D
assume cs:code,ds:data
data segment n1 dw 0444h n2 dw 4545h n3 dw ?
data ends code segment
start:
mov ax,data mov ds,ax
lea si,n1 lea di,n2 mov ax,[si] mov bx,[di] add ax,bx
lea bp,n3 mov [bp],ax
int 3
code ends end start
19 000F 20
21 0011
22 0014
23
24
25
26 0017 27
28 0028 29
03 C3
BD 0004r 89 46 00
CC
0444 4545 ????
B8 0000s 8E D8
BE 0000r BF 0002r
RESULT -- AX= 4989 , SI=0000 , DI=0002, BP=0004 D 0004 0005 89 49
SUBTRACTION..USING INDIRECT ADDRESSING MODE..
1 2
3 0000
4 0000
5 0002
6 0004
7 0006
8
9 0000
10
11 0000
12 0000
13 0003
14
15 0005
16 0008
17 000B 8B 04
18 000D 8B 1D
assume cs:code,ds:data
data segment n1 dw 0aaaah n2 dw 4545h n3 dw ?
data ends
code segment
start:
mov ax,data mov ds,ax
lea si,n1 lea di,n2 mov ax,[si] mov bx,[di] sub ax,bx
lea bp,n3 mov [bp],ax
int 3
code ends end start
19 000F 20
21 0011
22 0014
23
24
25
26 0017 27
28 0018 29
RESULT:
2B C3
BD 0004r 89 46 00
CC
AAAA 4545 ????
B8 0000s 8E D8
BE 0000r BF 0002r
RESULT -- AX= 65 65 , SI=0000 , DI=0002, BP=0004 D 0004
0005
65 65
USING DIRECT ADDRESSING MODE....
ADDITION..CODE
1 2
3 0000
4 0000
5 0002
6 0004
7 0006
8
9 0000
10
11 0000
12 0000
13 0003
14
15 0005
16 0008
17 000C A3 0004r
18 000F BE 0004r
19
20 0012 CC 21
22 0013
23
assume cs:code,ds:data
data segment n1 dw 5aaah n2 dw 4545h n3 dw ?
data ends code segment
start:
mov ax,data mov ds,ax
mov ax,n1 add ax,n2 mov n3,ax lea si,n3
int 3
code ends end start
5AAA 4545 ????
B8 0000s 8E D8
A1 0000r 03 06 0002r
RESULT -- AX= 9FEF , SI=0004 ; D 0004 0005 EF 9F
SUBTRACTION -- CODE
1 2
3 0000
4 0000
5 0002
6 0004
7 0006
8
9 0000
10
11 0000
12 0000
13 0003
14
15 0005
16 0008
17 000C A3 0004r
assume cs:code,ds:data
data segment n1 dw 5aaah n2 dw 4545h n3 dw ?
data ends code segment
start:
mov ax,data mov ds,ax
mov ax,n1 sub ax,n2 mov n3,ax
5AAA 4545 ????
B8 0000s 8E D8
A1 0000r 2B 06 0002r
6
18 000F BE 0004r 19
20 0012 CC
21
22 0013 23
lea si,n3 int 3
code ends end start
RESULT... AX= 6565 , SI=0004 ; D 0004 0005
So, Here are the codes so please go through very carefully and try to understand properly and if any doubt ask in comment section.I'll be happy to solve problem regarding this code.