473,322 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Assembly code programs

1) Write a program to determine the correct admission price to a movie. The price of admission to a movie is $7 for kids (under 12) and $9 for adults. Display the correct admission fee after the user gives you the age for one person.

Sample Run #1:
? 21
9

Sample Run #2:
? 11
7

This is what i have so far... I keep getting a unknown ALU operation. Please Help

Expand|Select|Wrap|Line Numbers
  1. INP 26
  2. LDA 26
  3. LDB 23
  4. CMP
  5. JGT 25
  6. JLT 24
  7.  
  8.  
  9.  
  10. PNT 24
  11. PNT 25
  12. STP
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24. 12
  25. 7
  26. 9
  27.  
Oct 7 '06 #1
5 3660
Banfa
9,065 Expert Mod 8TB
It is not possible to get an any more platfrm specific language than assembly code (there is machine code but that isn't really a language that is the actual code that runs on the machine).

Since you have failed to mention the platform you are working on it is anybodys guess what might be valid assembly code.
Oct 7 '06 #2
Ok, here are the instructions that i can use and they are used on a 32 bit processor.

STP Stop the program
LDA Load register A with value from a specified memory location
LDB Load register B with value from a specified memory location
STR Store register B value to a specified memory location
INP Store data input by user to a specified memory location
PNT Print the value stored in a specified memory location to the screen
JLT Jump if less than (Status register = -1) to a specified memory location
JGT Jump if greater than (Status register = 1) to a specified memory location
JEQ Jump if equal (Status register = 0) to a specified memory location
JMP Unconditional jump to a specified memory location
CMP Compare register A to register B and set Status Register value
ADD Add (register A + register cool.gif and store sum in register B
SUB Subtract (register A - register cool.gif and store difference in register B
MUL Multiply (register A * register cool.gif and store product in register B
DIV Divide for quotient (register A/register cool.gif and store quotient in register B
MOD Divide for remainder (register A/register cool.gif and store remainder in register B

Using 32 memory locations starting at 0 - 31
Oct 8 '06 #3
Our assembly language instructions have two parts:
The operation code specifies the operation the computer is to carry out (add, compare, etc)
An address that allows the instruction to refer to a location in main memory
The CPU runs each instruction in the program, starting with instruction 0, using the fetch-decode-execute cycle.
Oct 8 '06 #4
D_C
293 100+
Expand|Select|Wrap|Line Numbers
  1. INP 26
  2. LDA 26
  3. LDB 23
  4. CMP
  5. JLT 25 // jump if under 12
  6. PNT 25 // print 9 (12 or older)
  7. JMP // don't print 7 though
  8. PNT 25 //JLT here (print 7 for under 12)
  9. STP // JMP HERE
  10. ...
  11. 12
  12. 7
  13. 9
Oct 8 '06 #5
I run your code but it does not work correctly. What I am mising? What is on line 10? Thanks
Aug 22 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Bob Jenkins | last post by:
Sorry, I am new to programming, can you tell me why we need to learn assembly ? What advantages/disadvantages does it have ? Please answer this, can you tell me if there is any program able to...
3
by: David A. Beck | last post by:
We have developed systems for a client with VB, SQL Server, IIS, and ASP. We are in the process of doing all new work in .NET. We set up two directories on a file server. One for the executables...
2
by: Scott | last post by:
Does anyone know of a way to get the .NET Framework version that's required by a specified assembly. I have a program I've written that creates a Windows Installer setup for any application....
3
by: Chris Litschauer | last post by:
hi, I've a problem with vbc I've created an assembly with the new dotnet language cule.net (http://www.culeplace.net/) and tried to use the class of this assembly in a vb.net class. but I...
3
by: Richard Lewis Haggard | last post by:
We are having a lot of trouble with problems relating to failures relating to 'The located assembly's manifest definition with name 'xxx' does not match the assembly reference" but none of us here...
34
by: priyanka | last post by:
Hi, I was wondering if we could parse or do something in the executable( whose source language was C). How can I use some scripting language like perl/python to find out the information about...
85
by: fermineutron | last post by:
Some compilers support __asm{ } statement which allows integration of C and raw assembly code. A while back I asked a question about such syntax and was told that __asm is not a part of a C...
2
by: =?Utf-8?B?cm1m?= | last post by:
I got a trojan win 32 virus and had to do a system recovery. Afterwards, I had problems with .net framework 2.0. I tried to reinstall it on windows update and got *** error 25015 failed to install...
6
by: Piotrekk | last post by:
Hi In my solution I have two projects. First is Library project. The second project uses this library ( dll ). I am registering this assembly in global assembly cache ( by .net configuration...
13
by: Robert Cloud | last post by:
Is it possible to include assembly language routines in C if I'm using a compiler which has an assembler such as gcc? could I include them in a main function or would I have to write a seperate...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.