Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

[General] Microprocessor small problem solving

Status
Not open for further replies.

a_rishi

Newbie level 2
Joined
May 1, 2015
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
19
Hi Everybody

Could you please help me;

I need to add even numbers and odd numbers separately and store the result in the Even sum and Odd sum register respectively.

I'm trying a code as follow. I'm a complete novice in microprocessor.

Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
. model small
 
.data
 
ARRAY dB 45H, 07H, 61H, 47H, 17H, 16H, 08H, 55H, 63H, 74H
 
Even Sum dB ?
 
Odd Sum dB ?
 
.Code
 
START: MOV AX, @data
MOV DS, AX
MOV DI, 00H 
MOV DI,00H
MOV CL, 0AH
 
LABEL: MOV BL, ARRAY [DI]
MOV AL,BL
RCR AL,1
JNC EV
INC DI
DEC CL
JC OD
 
END LABEL
END
 
EV: MOV AL, DL
 
MOV Sum, DH
 
END EV
END


Please help to complete and correct the errors. Thanks in advance
 
Last edited by a moderator:

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
18,074
Helped
4,052
Reputation
8,104
Reaction score
3,966
Trophy points
113
Activity points
119,276
Hi,

What controller?

The routine "OD" is completely missing.

What do you try to achieve with this?
Code:
MOV DI, 00H 
MOV DI,00H
It seems to me this is a first try from "zero".

Please try to go through tutorials.
Then try to do your changes on existing code.
After you understand what happens, then try to write your own code. May be also starting from an existing code.


Klaus
 

Gorgon

Full Member level 6
Joined
Nov 10, 2005
Messages
345
Helped
75
Reputation
150
Reaction score
67
Trophy points
1,308
Location
Norway
Activity points
3,637
Any reason each sum should only be one byte?
Your allocation of sums look to be in code memory, not RAM. I would think DS is a better definition parameter, and you need to add the size of each sum.

The syntax is also odd, but since we don't know the assembler it's early to say.
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
According to the asm code it is x86 asm code and I guess he is using MASM.
 

a_rishi

Newbie level 2
Joined
May 1, 2015
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
19
According to the asm code it is x86 asm code and I guess he is using MASM.
Hi Everybody

Yes it is x86 code.

The code is not complete. If you could write a small code such that the array of numbers be added separately (i.e odd and even number) and store the even sum in a register and the odd sum in another register.

With respect to the above code, RCR (Rotate to the right with carry) is used to check the least significant bit (0 for even and jump to a sepaarte code EV for addition, whereas for 1 it jump to Odd code OD for sum).

Thanks
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top