This is topic anybody know pep/8 assembly language? in forum General Talk at Northern California Ford Owners  .


To visit this topic, use this URL:
https://californiafords.com/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=1;t=022661

Posted by blind (Member # 3052) on :
 
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]
 
Posted by blind (Member # 3052) on :
 
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]
 
Posted by blind (Member # 3052) on :
 
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 ]
 
Posted by MustyTang (Member # 896) on :
 
So does it work ok when you put a negative value in for A and C?
 
Posted by blind (Member # 3052) on :
 
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 ]
 
Posted by MustyTang (Member # 896) on :
 
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??
 
Posted by two-gun kid (Member # 5891) on :
 
what is pep8?
 
Posted by DOPE 50 (Member # 5892) on :
 
WTF DOES ALL THAT MEAN [Confused]
 
Posted by MustyTang (Member # 896) on :
 
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.
 
Posted by blind (Member # 3052) on :
 
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
 
Posted by blind (Member # 3052) on :
 
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]
 




Fueled by Ford Mustang Owners
on CaliforniaFords.com