Northern California Ford racer's Message Board Forum Sell & Buy Ford Parts in Northern California Classifieds Mustang Pictures / Videos of Ford Cars in Northern California

Northern California Ford Owners  


Post New Topic  New Poll  Post a Ford message board Reply
read DMs/my profile login | join CAFords | search | faq |
  next oldest topic   next newest topic
» Northern California Ford Owners     » Automotive   » General Talk   » anybody know pep/8 assembly language?

 - Email this post to someone!    
Author Topic: anybody know pep/8 assembly language?
Blind
2.3L
CAFords OG
Member # 3052

Ford Icon 1 posted      Profile for Blind  Ford pictures for Blind    Send New Direct Message       Edit/Delete Post   Reply With Quote       Share this CAFords post on FB
I have an assignment and I'm stuck. Basically I have to write an algabra equation in pep/8.

I know how to do it in java, which works fine:

quote:

/**
* (1) Prompts the user for input (use the STRO instruction)
* (2) Inputs the value of three integers A, B and C
* (3) Outputs (with a label – use STRO again) the value of
* ( A / 4 ) + ( B % 8 ) + ( C * 7 ) + 103
*/
import javax.swing.*;

public class program1
{



public static void main(String args[]) //prompts the user for the values of a,b,c and stores them
{
int a,b,c,result;
String input;

input = JOptionPane.showInputDialog(null,
"What is the value of a:");
a = Integer.parseInt(input);

input = JOptionPane.showInputDialog(null,
"What is the value of b:");
b = Integer.parseInt(input);

input = JOptionPane.showInputDialog(null,
"What is the value of c:");
c = Integer.parseInt(input);

result = (a / 4) + (b % 8) + (c * 7) + 103;

System.out.println("The result of (A/4) + (B%8) + (C*7) + 103 = " + result);

}
}

now converting that to pep/8 is killing me, I know how to do the basic stro commands for a,b,c but doing the arithmatic shift left and shift right for the algebra equation is what I'm stuck on.

if anybody can give me a hand that would be awesome [patriot]

--------------------
89 LX Notchback ex 4cyl, 14psi
02 Harley F150, 15psi

Posts: 8521 | From: Fairfield | Registered: Jul 2003  |  :
Blind
2.3L
CAFords OG
Member # 3052

Ford Icon 1 posted      Profile for Blind  Ford pictures for Blind    Send New Direct Message       Edit/Delete Post   Reply With Quote       Share this CAFords post on FB
quote:

main: stro startmsg,d
A: .block 2
B: .block 2
C: .block 2
total: .block 2

deci A,d
deci B,d
deci C,d
lda A,d
asra
asra ; Reg A contains A/4
adda total,d
sta total,d ; Total contains (A/4)
lda B,d
anda 0x0007,i
adda total,d
sta total,d ; Added (B % 8) to total
adda total,d
sta total,d
lda C,d
adda C,d
adda C,d
adda C,d
adda C,d
adda C,d
adda C,d
adda C,d
adda total,d
sta total,d ; C * 7 added to Total
lda total,d
adda 103,d
sta total,d ; + 103 to total
lda total,d
stro msg,d ; "Total = "
deco total,d ; total
charo '\n',i
stop

startmsg: .ASCII "Enter 3 variables: a,b,c \x00"
msg: .ASCII "\nTotal = \x00"
.END

still stuck, someone help [Frown]

I've got all the math in there, but when I execute the program it wont take my input and output the total [Confused]

--------------------
89 LX Notchback ex 4cyl, 14psi
02 Harley F150, 15psi

Posts: 8521 | From: Fairfield | Registered: Jul 2003  |  :
Blind
2.3L
CAFords OG
Member # 3052

Ford Icon 1 posted      Profile for Blind  Ford pictures for Blind    Send New Direct Message       Edit/Delete Post   Reply With Quote       Share this CAFords post on FB
quote:
BR main
A: .block 2
B: .block 2
C: .block 2
total: .block 2

main: stro startmsg,d


deci A,d
deci B,d
deci C,d
lda A,d
asra
asra ; Reg A contains A/4
adda total,d
sta total,d ; Total contains (A/4)
lda B,d
anda 0x0007,i
adda total,d
sta total,d ; Added (B % 8) to total
adda total,d
sta total,d
lda C,d
adda C,d
adda C,d
adda C,d
adda C,d
adda C,d
adda C,d
adda C,d
adda total,d
sta total,d ; C * 7 added to Total
lda total,d
adda 103,d
sta total,d ; + 103 to total
lda total,d
stro msg,d ; "Total = "
deco total,d ; total
charo '\n',i
stop

startmsg: .ASCII "Enter 3 variables: a,b,c:\n\x00"
msg: .ASCII "\nTotal = \x00"
.END

program "works" but if I put a negative value for B then it gives me the wrong value [BS flag]

[ October 09, 2005, 06:15 PM: Message edited by: blind ]

--------------------
89 LX Notchback ex 4cyl, 14psi
02 Harley F150, 15psi

Posts: 8521 | From: Fairfield | Registered: Jul 2003  |  :
MustyTang
I love chocolate girls
Member # 896

Ford Icon 1 posted      Profile for MustyTang  Ford pictures for MustyTang    Send New Direct Message       Edit/Delete Post   Reply With Quote       Share this CAFords post on FB
So does it work ok when you put a negative value in for A and C?

--------------------
2004 Dark Shadow Gray Mustang GT

Posts: 2178 | From: Hayward, CA | Registered: Feb 2002  |  :
Blind
2.3L
CAFords OG
Member # 3052

Ford Icon 1 posted      Profile for Blind  Ford pictures for Blind    Send New Direct Message       Edit/Delete Post   Reply With Quote       Share this CAFords post on FB
yes

emailed my instructor and he said doing % for negatives at this point for pep/8 is too complex, my program is perfect for what he was asking [Whoo Whooooo!]

[ October 09, 2005, 10:55 PM: Message edited by: blind ]

--------------------
89 LX Notchback ex 4cyl, 14psi
02 Harley F150, 15psi

Posts: 8521 | From: Fairfield | Registered: Jul 2003  |  :
MustyTang
I love chocolate girls
Member # 896

Ford Icon 1 posted      Profile for MustyTang  Ford pictures for MustyTang    Send New Direct Message       Edit/Delete Post   Reply With Quote       Share this CAFords post on FB
Ya it's been awhile since I've done assembly language coding. I was googling to see if I could get some info, but it seemed like it was a lot more in depth. BTW...what is your anda 0x0007,i statement doing??

--------------------
2004 Dark Shadow Gray Mustang GT

Posts: 2178 | From: Hayward, CA | Registered: Feb 2002  |  :
two-gun kid2
¯
Member # 5891

Ford Icon 1 posted      Profile for two-gun kid2  Ford pictures for two-gun kid2    Send New Direct Message       Edit/Delete Post   Reply With Quote       Share this CAFords post on FB
what is pep8?
Posts: 5566 | From: Hayward,Ca | Registered: Jul 2005  |  :
DOPE 50
¯
Member # 5892

Ford Icon 1 posted      Profile for DOPE 50  Ford pictures for DOPE 50    Send New Direct Message       Edit/Delete Post   Reply With Quote       Share this CAFords post on FB
WTF DOES ALL THAT MEAN [Confused]

--------------------
94 COBRA CLONE CONVERTIBLE
67 SS CHEVY NOVA,CAGED UP,TUBBED,FUEL CELL,ETC..IN THE WORKS.[67SSNOV]
91 INTEGRA ON 17'S
94 Ranger Getting lifted

Posts: 637 | From: THE BAY | Registered: Aug 2005  |  :
MustyTang
I love chocolate girls
Member # 896

Ford Icon 1 posted      Profile for MustyTang  Ford pictures for MustyTang    Send New Direct Message       Edit/Delete Post   Reply With Quote       Share this CAFords post on FB
quote:
Originally posted by DOPE 50:
WTF DOES ALL THAT MEAN [Confused]

Basically it's a bunch of coding that is needed to solve a simple equation of (A/4) + (B%8) + (C*7) + 103 where the user inputs the values of A, B, & C.

--------------------
2004 Dark Shadow Gray Mustang GT

Posts: 2178 | From: Hayward, CA | Registered: Feb 2002  |  :
Blind
2.3L
CAFords OG
Member # 3052

Ford Icon 1 posted      Profile for Blind  Ford pictures for Blind    Send New Direct Message       Edit/Delete Post   Reply With Quote       Share this CAFords post on FB
quote:
Originally posted by MustyTang:
Ya it's been awhile since I've done assembly language coding. I was googling to see if I could get some info, but it seemed like it was a lot more in depth. BTW...what is your anda 0x0007,i statement doing??

that is doing the (B % 8) portion.

I changed it to be anda 8,i so its easier for me to read actually

--------------------
89 LX Notchback ex 4cyl, 14psi
02 Harley F150, 15psi

Posts: 8521 | From: Fairfield | Registered: Jul 2003  |  :
Blind
2.3L
CAFords OG
Member # 3052

Ford Icon 1 posted      Profile for Blind  Ford pictures for Blind    Send New Direct Message       Edit/Delete Post   Reply With Quote       Share this CAFords post on FB
quote:
Originally posted by two-gun kid:
what is pep8?

its version 8 of an assembly language, basically there's a few kinds of programming you can do to make a computer work for you.

binary (lowest level)
assembly
and then you get into the "high level" like basic, C, perl, C++, Java, etc

I prefer java personally, I find it easier than C.

in case anyone care's here's my final program as it sits now, it works for all positive numbers. The one I posted above worked but it wasn't storing the calculations properly and was giving junk output.
quote:

; Kevin Tansey
; Program #1
; October 2005

; A program that accepts 3 variables from the user,
; performs the equation "(A/4)+(B%8)+(C*7)+103"
; And prints the result.

BR main

; Variables

A: .block 2
B: .block 2
C: .block 2
total: .block 2

main: stro startmsg,d
deci A,d
deci B,d
deci C,d

lda A,d
asra
asra ; (A / 4)
sta A,d

lda B,d
anda 0x0007,i ; (B % 8)
sta B,d

lda C,d
adda C,d
adda C,d
adda C,d
adda C,d
adda C,d
adda C,d ; (C * 7)
sta C,d

lda A,d ; (A/4)
adda B,d ; + (B % 8)
adda C,d ; + (C * 7)
adda 103,i ; + 103
sta total,d ; = total

stro endmsg,d ; "Total = "
deco total,d ; total
charo '\n',i
stop

startmsg: .ASCII "Enter 3 variables: a,b,c:\n\x00"
endmsg: .ASCII "\nTotal = \x00"
.END

exactly what I wanted to spend my entire friggen Sunday doing, especially when I have a new set of headers I could have thrown on my car this weekend [Roll Eyes]

I'm all done though, I feel good so now its time to have some JD to celebrate [dance] [Big Grin]

--------------------
89 LX Notchback ex 4cyl, 14psi
02 Harley F150, 15psi

Posts: 8521 | From: Fairfield | Registered: Jul 2003  |  :


 
Post New Topic  New Poll  Post a Ford message board Reply Close Topic   Feature Topic   Move Topic   Delete Topic next oldest topic   next newest topic
 - Printer friendly view of this Ford topic
Hop To:

Questions/Requests/Suggestions? email CAFords



Fueled by Ford Mustang Owners
on CaliforniaFords.com