-
-
Save mathewmariani/91f471422c4ac0b5ee37 to your computer and use it in GitHub Desktop.
ORG 0 | |
LOAD X / LOAD X into AC | |
ADD Y / ADD Y to AC | |
STORE Z / STORE AC in Z | |
LOAD Z / LOAD Z into AC | |
OUTPUT / OUTPUT AC | |
X, DEC 1 / variable declaration | |
Y, DEC 2 / variable declaration | |
Z, DEC 0 / variable declaration |
ORG 0 | |
Cond, LOAD COUNT / LOAD count into AC | |
SUBT ARRAY / SUBTRACT array[0] from AC | |
SKIPCOND 000 / Skipcond 000 if AC < 0 | |
JUMP End / JUMP to End | |
Loop, LOAD COUNT / LOAD Count into AC | |
ADD ONE / ADD ONE to AC | |
STORE COUNT / STORE AC into COUNT | |
LOADI INDEX / LOAD MEM[index] into AC | |
OUTPUT / OUTPUT value at index | |
LOAD INDEX | |
ADD ONE | |
STORE INDEX | |
JUMP Cond / JUMP to Cond | |
End, LOAD START / LOAD start into AC | |
STORE INDEX / STORE AC into index | |
HALT / HALT process | |
INDEX, HEX 013 / Our current memory location | |
START, HEX 013 / The memory location of our first value (in hex) | |
ARRAY, DEC 5 / The first index of our array (used for size) | |
DEC 0 / index 0 | |
DEC 2 / index 1 | |
DEC 4 / index 2 | |
DEC 8 / index 3 | |
DEC 16 / index 4 | |
COUNT, DEC 0 | |
/ constant values | |
ZERO, DEC 0 | |
ONE, DEC 1 | |
TWO, DEC 2 | |
THREE, DEC 3 | |
FOUR, DEC 4 | |
FIVE, DEC 5 | |
SIX, DEC 6 | |
SEVEN, DEC 7 | |
EIGHT, DEC 8 | |
NINE, DEC 9 | |
TEN, DEC 10 |
ORG 0 | |
Cond, LOAD COUNT / Load count into AC | |
SUBT TEN / Remove 10 from count | |
SKIPCOND 000 / Skipcond 000 if AC < 0 | |
JUMP End / End Loop | |
Loop, LOAD COUNT / Load count into AC | |
ADD ONE / Increment Count by 1 | |
STORE COUNT / Store AC in count | |
JNS Fibb | |
JUMP Cond / Check loop conditions | |
Fibb, HEX 000 / Store value for JNS | |
CLEAR / AC = 0 | |
/ Fi = F1 + F2 | |
ADD F1 / AC + F1 | |
ADD F2 / AC + F2 | |
STORE Fi / Fi = AC | |
/ F1 = F2 | |
LOAD F2 / AC = F2 | |
STORE F1 / F1 = AC | |
/ F2 = Fi | |
LOAD Fi / AC = Fi | |
STORE F2 / F2 = AC | |
/ Quick Output | |
LOAD Fi / AC = FI | |
OUTPUT / Output AC | |
JUMPI Fibb | |
End, HALT / Halt process | |
/ variables | |
COUNT, DEC 0 / count for loop | |
Fi, DEC 0 | |
F1, DEC 0 | |
F2, DEC 1 | |
/ constant values | |
ZERO, DEC 0 | |
ONE, DEC 1 | |
TWO, DEC 2 | |
THREE, DEC 3 | |
FOUR, DEC 4 | |
FIVE, DEC 5 | |
SIX, DEC 6 | |
SEVEN, DEC 7 | |
EIGHT, DEC 8 | |
NINE, DEC 9 | |
TEN, DEC 10 |
/ This program presents a simple add(a, b) function. | |
/ #L8-9 Sets the argument `add_a` for the add function. | |
/ #L10-11 Sets the argument `add_b` for the add function. | |
/ #L12 Calls the add function using JNS which stores the current PC to be used as a callback | |
/ #L21 Indirectly jumps back to where the function was called from. | |
ORG 0 | |
LOAD X | |
STORE add_a | |
LOAD Y | |
STORE add_b | |
JNS add | |
OUTPUT | |
HALT | |
add_a, DEC 0 | |
add_b, DEC 0 | |
add, HEX 0 | |
LOAD add_a | |
ADD add_b | |
JUMPI add | |
/ variables | |
X, DEC 1 | |
Y, DEC 2 |
ORG 0 / implemented using "do while" loop | |
WHILE, LOAD STR_BASE / load str_base into ac | |
ADD ITR / add index to str_base | |
STORE INDEX / store (str_base + index) into ac | |
CLEAR / set ac to zero | |
ADDI INDEX / get the value at ADDR | |
SKIPCOND 400 / SKIP if ADDR = 0 (or null char) | |
JUMP DO / jump to DO | |
JUMP END / JUMP to END | |
DO, OUTPUT / output value at ADDR | |
LOAD ITR / load iterator into ac | |
ADD ONE / increment iterator by one | |
STORE ITR / store ac in iterator | |
JUMP WHILE / jump to while | |
END, HALT | |
ONE, DEC 1 | |
ITR, DEC 0 | |
INDEX, HEX 0 | |
STR_BASE, HEX 12 / memory location of str | |
STR, HEX 48 / H | |
HEX 65 / E | |
HEX 6C / L | |
HEX 6C / L | |
HEX 6F / O | |
HEX D / carriage return | |
HEX 57 / W | |
HEX 6F / O | |
HEX 72 / R | |
HEX 6C / L | |
HEX 64 / D | |
HEX 0 / NULL char |
/ #L10 Is beginning of an if control block, where an the value of an expression is determined. | |
/ In this case were comparing `EXP` to 0. | |
/ #L14 Is the body of the if statement, we output `IVALUE` and `JUMP` to `end`. | |
/ We `JUMP` to avoid running code from `else`. | |
/ #L18 Is the body of the else statement, we output `EVALUE` and continue running the program. | |
/ Unlike the body of the if statment we don't need to `JUMP`; instead we can continue. | |
/ #L11 If `EXP` is not 0 then then SKIPCOND will not skip over #L12 forcing a `JUMP`. | |
ORG 0 | |
if, LOAD EXP / LOAD EXP into AC | |
SKIPCOND 400 / SKIPCOND 400 (if AC = 0) | |
JUMP else / JUMP to `else` | |
LOAD IVALUE / LOAD IVALUE into AC | |
OUTPUT / OUTPUT value IVALUE | |
JUMP end / JUMP to `end` | |
else, LOAD EVALUE / LOAD IVALUE into AC | |
OUTPUT / OUTPUT value IVALUE | |
end, HALT / HALT | |
/ variables | |
EXP, DEC 1 | |
IVALUE, DEC 2 | |
EVALUE, DEC 3 |
ORG 0 / implemented using a "for" loop | |
Cond, LOAD COUNT / LOAD count into AC | |
SUBT TEN / SUBTRACT 10 from AC | |
SKIPCOND 000 / Skipcond 000 if AC < 0 | |
JUMP End / JUMP to End | |
Loop, LOAD COUNT / LOAD Count into AC | |
ADD ONE / ADD ONE to AC | |
STORE COUNT / STORE AC into COUNT | |
LOAD COUNT / LOAD count into AC | |
OUTPUT / OUTPUT AC | |
JUMP Cond / JUMP to Cond | |
End, HALT / HALT process | |
COUNT, DEC 0 | |
/ constant values | |
ZERO, DEC 0 | |
ONE, DEC 1 | |
TWO, DEC 2 | |
THREE, DEC 3 | |
FOUR, DEC 4 | |
FIVE, DEC 5 | |
SIX, DEC 6 | |
SEVEN, DEC 7 | |
EIGHT, DEC 8 | |
NINE, DEC 9 | |
TEN, DEC 10 |
ORG 0 | |
LOAD X / LOAD X into AC | |
SUBT Y / SUBTRACT Y from AC | |
STORE Z / STORE AC in Z | |
LOADZ / LOAD Z into AC | |
OUTPUT / OUTPUT AC | |
X, DEC 2 / variable declaration | |
Y, DEC 1 / variable declaration | |
Z, DEC 0 / variable declaration |
/ This program presents a simple tolower(ptr) function. | |
/ #L8-9 Sets the argument `str_ptr` for the tolower function. | |
/ #L10 Calls the tolower function. | |
/ #L27 Adds the offset between upper and lower case letters on ascii table. | |
/ 0x41 ('A') 0x61 ('a') --> 0x20 | |
ORG 0 | |
LOAD str_ptr | |
STORE tolower_ptr | |
JNS tolower | |
HALT | |
tolower_itr, DEC 0 | |
tolower_ptr, HEX 0 | |
tolower_idx, HEX 0 | |
tolower_offset, HEX 20 | |
tolower, HEX 0 | |
tolower_while, LOAD tolower_ptr | |
ADD tolower_itr | |
STORE tolower_idx | |
CLEAR | |
ADDI tolower_idx | |
SKIPCOND 400 | |
JUMP tolower_do | |
JUMPI tolower | |
tolower_do, ADD tolower_offset | |
OUTPUT | |
LOAD tolower_itr | |
ADD ONE | |
STORE tolower_itr | |
JUMP tolower_while | |
str_ptr, HEX 18 / memory location of str | |
str, HEX 48 / H | |
HEX 45 / E | |
HEX 4C / L | |
HEX 4C / L | |
HEX 4F / O | |
HEX D / carriage return | |
HEX 57 / W | |
HEX 4F / O | |
HEX 52 / R | |
HEX 4C / L | |
HEX 44 / D | |
HEX 0 / NULL char | |
/ constants | |
ONE, DEC 1 |
ORG 0 / implemented using a "for" loop | |
INPUT / INPUT into AC | |
STORE MAX / STORE AC into MAX | |
Cond, LOAD COUNT / LOAD count into AC | |
SUBT USR / SUBT MAX from AC | |
SKIPCOND 000 / Skipcond 000 if AC < 0 | |
JUMP End / JUMP to End | |
Loop, LOAD COUNT / LOAD Count into AC | |
ADD ONE / ADD ONE to AC | |
STORE COUNT / STORE AC into COUNT | |
LOAD COUNT / LOAD count into AC | |
OUTPUT / OUTPUT AC | |
JUMP Cond / JUMP to Cond | |
End, HALT / HALT process | |
/ variables | |
COUNT, DEC 0 | |
MAX, DEC 0 | |
/ constants | |
ZERO, DEC 0 | |
ONE, DEC 1 | |
TWO, DEC 2 | |
THREE, DEC 3 | |
FOUR, DEC 4 | |
FIVE, DEC 5 | |
SIX, DEC 6 | |
SEVEN, DEC 7 | |
EIGHT, DEC 8 | |
NINE, DEC 9 | |
TEN, DEC 10 |
anyone know how to get the 10s place of a dec?
I'm trying to print a 2 digit number in ascii so I can include spaces
i have tried building converting this from JS to marie...
https://stackoverflow.com/questions/24226324/getting-place-values-of-a-number-w-modulus
this is the result.. i think my devide works
printNumber, HEX 000//2 diget print
//set ones
load numToPrint
store numerator
load ten
store denominator
JnS devide
load count
store ones
//ones=num%10
//set tens
load numToPrint
store numerator
load ten
store denominator
JnS devide
//count=num/10
load count
store numerator
load ten
store denominator
JnS devide
load remainder
store tens
//tens=count%10
load tens
add offset
output
load ones
add offset
output
jumpI printNumber
devide, HEX 000//JnS devide// denominator, numerator >> remainder, count
load numerator
//store tt
test, load numerator
subt denominator
store numerator
//count it
load count
add one
store count
//if we have some more numerator do again
load numerator
Skipcond 000//if we have some more numerator do again
jump test
Skipcond 800//if we are negative rewind and get the diffrence
jump getRemainder
jumpI devide//return
//numerator
getRemainder, load count
subt one
store count//remove one from count
load numerator
add denominator//add the denominator back to pre last test
store remainder
jumpI devide//return
but i am 21 instead of 13...
would you like to give some help on clear up all the spaces in the user input
hi i need help for this .
Using MARIE, create a program that will accept as input the user's first name and output "Hello, [user's input]!"
Can you help me with this?
Write a MARIE program that accepts an integer from the user, and if it is a prime number the program will output 1, otherwise, the program will output 0.
Examples:
If the user input is 17, the output would be 1
If the user input is 2, the output would be 1
If the user input is 15, the output would be 0
If the user input is -2, the output would be 0You should write and run the program using MARIE simulator. Add enough comments to understand your code.
You do not have to include the .mas file in the submission. Instead, the code should be presented as a word-processed section in the assignment, not as an image. Insert images to show you have tested the code with several possibilities.
BRO You from CSU??
Please feel free to email me if you have any questions.
Can you help me with the following question please. Urgent
MARIE program to calculate some basic statistics on a list of positive numbers. The program will ask users to input the numbers one by one. Assume that all numbers will be in the range 1 to 1000. To terminate the data entry, the user will input any negative number. Once the data entry is complete, the program will show four statistics about the list of numbers:
(i) Count, (ii) Minimum value, and (iii) Sum of the numbers.
As an example, if the user enters the following decimal numbers as input (one after the other)
23, 6, 78, 36, 3, 250, 127, 210, -5
the program would output the following values as the count, minimum and sum respectively:
8
3
733
Assume that the user will always provide valid numbers as input, that is, do not worry about dealing with invalid input data.
Write comments within your program so that a reader can understand it easily.
Can you please help me with this Marie program. Please it's urgent!
Write a MARIE program to allow the user to input 8 integers (positive, negative, or zero) and then find the smallest and the largest and print each of these out.
As an example, if the user enters the following decimal numbers as input (one after the other)
23, -6, 78, 0, 36, 3, -250, –5
the program would output the following values as the maximum and minimum, respectively:
78
-250
Assume that the user will always provide valid numbers as input; that is, do not worry about dealing with invalid input data.
same problem
Can you please help me with this Marie program. Please it's urgent!
Write a MARIE program to allow the user to input 8 integers (positive, negative, or zero) and then find the smallest and the largest and print each of these out.
As an example, if the user enters the following decimal numbers as input (one after the other)
23, -6, 78, 0, 36, 3, -250, –5
the program would output the following values as the maximum and minimum, respectively:
78
-250Assume that the user will always provide valid numbers as input; that is, do not worry about dealing with invalid input data.
CSU IT FUNDAMENTALS?
Can you please help me with this Marie program. Please it's urgent!
Write a MARIE program to allow the user to input 8 integers (positive, negative, or zero) and then find the smallest and the largest and print each of these out.
As an example, if the user enters the following decimal numbers as input (one after the other)
23, -6, 78, 0, 36, 3, -250, –5
the program would output the following values as the maximum and minimum, respectively:
78
-250Assume that the user will always provide valid numbers as input; that is, do not worry about dealing with invalid input data.
same problem
I have the solution, let me know if you still need it.
Hello, I really need your help now because I really don't know how to write the MARIE code.
Using the Marie Simulator found on the web site, you will create a small assembly language Marie program. The program is a VERY simple addition tool. Basically, your program will issue a prompt (">"), then accept a single digit integer from the user. (Hit the ENTER key to actually enter the value). It will then echo that integer to the screen, print a "+” symbol, then wait for a second digit. It will then echo this digit to the screen, followed by the "=" symbol and then the result of the addition. There is no error checking, so all numbers entered should be a single digit, and the result must also be a single digit. So 1+3=4 is okay, but 7+9=16 is not (i.e., your program is not expected to be able to handle the second case properly). When the calculation is finished, you must tell the program whether to continue or not. If you enter a "!", the program will print "BYE" to the screen and halt. If you simply hit the ENTER key instead, it will loop and provide a new prompt. Note that IO is quite limited on Marie so you can't do anything fancy. You should select the "no linefeed" option in the Output Window - everything will be printed on one line. A sample output for a two iteration loop would be something like this: > 3+2=5>1+2=3BYE You will hand in your source file with your submission. It should be called adder.mas. The tutor will assemble and run your source code.
Can you please help me the code for question above? I can etransfer for you if need. I really need the code. Thank you so much
Please feel free to email me if you have any questions.
Hi can someone pls tell me the code for checking for palindrome using MARIE code ? The palindrome needs to be checked for the user input which I managed to create . So basically what I want to do is check for palindrome in the input I enter and if it is a palindrome output 1 . PLS PLS reply to this
Please feel free to email me if you have any questions.
where can I find your email ?
where can I find your email ?
It can be found on my GitHub
Hi, can someone help me with this question. I don't get how you can input in operations like "+, -, *" and use to get the sum of the numbers you already inputted.
Here are the questions:
- Using the INPUT instruction wait for the user to enter an integer number.
a. Be sure the dropdown for the Input field says Decimal - Using the INPUT instruction wait for the user to enter a second integer number.
a. Be sure the dropdown for the Input field says Decimal - Using the INPUT instruction wait for the user to enter the character +, - or *.
a. Be sure the dropdown for the Input field says ASCII. Then type the symbol for the operation you want, i.e. “+”, “-“, etc. - Perform the desired addition, subtraction or multiplication operation.
- Store the result in a variable in memory.
- Display the result via the OUTPUT instruction.
Thank you!
@areaknight99 Please read the other comments. I do not answer questions here but you can email me.
Write a MARIE program that outputs "YES" on the display when A>B and prints "NO" otherwise. For comparisons, the program must not use SKIPCOND 400 or SKIPCOND 800; it will use SKIPCOND 000 only
Dear help me...
Code not working properly
/ *****
/ This is starting code for Project 2
/ Remove this header and identify your project name and your name.
/
/ *****
ORG 100 / Start the program at location 100 hexadecimal
/ -----
/ Input characters, transform, and store in memory until '.' is input
/ -----
Load Start / Initialize character pointer to start of block
Store Ptr
GetVal, Input /Take the input value
Subt ChPe / subroutine '.' (2E)
Skipcond 800 / AC will be 00, if the input is '.'
/jump Print we're done entering, now go print
input / get next array element
/>>>>> Add code to accomplish the input and output phases. <<<<<
/>>>>> Here's an example of how subroutine ROT13 is called. <<<<<
/>>>>> We'll just transform 'A' in this example then halt. Load ChA / Put 'A' in AC
Store InVal / Store value to be transformed into InVal
Jns ROT13 / Jump to the ROT13 subroutine
/ Upon return, the transformed character is in AC
storeI Ptr / store in arr[index]
load Ptr / Ptr++
add Incr
store Ptr
load Index / Index++
add Incr
store Index
jump GetVal / return to loop tes
Halt
Print, load Arr / copy array address
load Arr
store Ptr
clear / Index = 0
store Index
PrtVal, loadI Ptr / get/print next element from arr[index]
output
load Ptr / Ptr++
add Incr
store Ptr
load Index / Index++
add Incr
store Index
Jump PrtVal / return to loop test
/ -----
/ Rotate-13 subroutine: Apply ROT13 to input character in location InVal and return in AC
/ -----
/>>>>> WARNING: This subroutine almost works. You need to fix a bug.
ROT13, HEX 0
Load InVal / Get character
Add Val13 / Add 13
Store Hold / Save it
Subt ChZ / Check if modulo adjust is needed (past 'Z')
Skipcond 800 / No adjust needed if past 'Z'
Jump NoAdj
Add ChA / Add 'A' back to difference to perform modulo
Jump Done / Result is in AC
NoAdj, Load Hold / No adjust needed, get result
Done, Jump ROT13 / Return with result in AC
/ -----
/ Constants (the program should not write to these locations)
/ -----
ChA, HEX 0041 / Constant value 'A' for modulo adjust in subroutine
ChZ, HEX 005A / Constant value 'Z' for modulo check in subroutine
ChPe, HEX 2E / Constant period character that marks end of input
Val13, DEC 13 / Constant rotate value of 13 for subroutine
One, HEX 1 / Constant value 1
Start, HEX 200 / Constant address for start of character block
/ -----
/ Data area (these locations are for reading and writing)
/ -----
InVal, HEX 0 / subroutine for subroutine input value
Hold, HEX 0 / Reserved for temporary variable for subroutine
Ptr, HEX 0 / Reserved for character pointer
Index, hex 0 / current array index
Element, hex 0 / value of current array element
Incr, hex 1 / for ++
Arr, hex 28 / address for start of the array storage
@mathewmariani Please check my email!
Can you please show me how to write a program to print an odd number in marie?