Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,582 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,929 people online right now. Registration is fast and FREE... Join Now!




HELp w/Intro to Assembly Language, PEP/8

 
Reply to this topicStart new topic

HELp w/Intro to Assembly Language, PEP/8, confused on how to use 'branch'

xetulul
7 Oct, 2008 - 02:16 PM
Post #1

New D.I.C Head
*

Joined: 7 Sep, 2008
Posts: 9

Im having problems understanding branches. I don't really know how to use it, but I gave it a shot, shown below in code.
PROGRAM
-----------------------------------------------------------------------------------------------------------------------------------
Note that the PEP/8 instruction set does not provide a multiply instruction, so solution will implement multiplication as repeated addition. In Java, the program would look like this:

int x = 7; // multiplicand
int y = 5; // multiplier (loop limit)
int z = 0; // accumulator (product)
int i = 1; // counter
while (i<=y) {
z = z + x; // add multiplicand to accumulator
i = i + 1; // increment counter
}


CODE

LDA 0X0007,i
sta 0x0037,d; store in x
lda 0x0005,i
sta 0x0039,d; store in y
lda 0x0000,i;
sta 0x003B,d;  store in z
lda 0x0001,i
sta 0x003D,d; store in i
LDA 0x0039,d; load y
CPA 0x003D,d; Y with I
BRGE 0x0036,i; START BRANCH
LDA 0x003B,d ; z
ADDA 0x0037,d; x
STA 0x003B,d ; z
LDA 0x003D,d ; i
ADDA 0x0001,i; i+1
STA 0x003D,d ; i
BR 0x001B,i;   BRANCH BACK
STOP
.word 0x0000; x
.word 0x0000; y
.word 0x0000; z
.word 0x0000; i
.end

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 12:36AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month