-
-
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 |
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!
@areaknight99 Please read the other comments. I do not answer questions here but you can email me.