Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assembly language programming

Status
Not open for further replies.

Berlisen

Programmer
Feb 23, 2012
1
0
0
CA
Hi Guys


I am fairly new at assembly languages and I need to learn how to do a simple program

what it would do is take 3 stacks, one with three characters and one with numbers 1-3(in random order) and the third one would be empty.

Basically I want to make a program that takes the letter from the first stack and check its number on the second stack and essentially put it in that order on the third stack

So for example if the character was B and the number was 2 then B would be BETWEEN the two other characters at the end of the script.

so assume the stacks were like this (before the program)

Stack 1 Stack 2 Stack 3(empty)
B 1 -
A 3 -
D 4 -
E 5 -
L 2 -

After the program stack 3 would look like this

Stack 3
B
L
A
D
E

It would be nice if stacks A and B were not effected

And it does not necessarily have to be a letter as long as all the data in stack A is the same size.

I know this might be much but it would really help me a lot.


thanks.
 
I hope it works!

iterate trough stack and find a match ex. for number 1
la r4,1
la r5,stack2
la r6,0
la r7,stack1
sr r5,r7
lr r7,r5
la r5,stack2
loop c r4,0(r6,r5)
be tost3
la r6,1(r6)
b loop
tost3 la r9,stack3
ar r9,r6
ar r6,r5
sr r6,r7
mvc 0(0,r9),0(r6)
la r6,0
la r4,1(r4)
c r4,stklen
bnh loop
l r13,save+3
return (14,12)
stack1 dc al1(c'b',c'a'....)
stack2 dc a(x'000001',x'00000003'...)
stack ds Xal1 x is the number of elements in stacks
stklen dc x'XY' xy=num of elemetts in hex
yregs
end


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top