Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brendon45/monty
This repository is for Monty byte codes
https://github.com/brendon45/monty
Last synced: about 2 months ago
JSON representation
This repository is for Monty byte codes
- Host: GitHub
- URL: https://github.com/brendon45/monty
- Owner: Brendon45
- Created: 2023-12-12T13:12:42.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-02-19T13:29:49.000Z (11 months ago)
- Last Synced: 2024-02-19T14:47:58.406Z (11 months ago)
- Language: C
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 0x19. C - Stacks, Queues - LIFO, FIFO
## C
## Group project
## Algorithm
## Data structure## Requirements
## General
- Allowed editors: vi, vim, emacs
- All your files will be compiled on Ubuntu 20.04 LTS using gcc, using the options -Wall -Werror -Wextra -pedantic -std=c89
- All your files should end with a new line
- A README.md file, at the root of the folder of the project is mandatory
- Your code should use the Betty style. It will be checked using betty-style.pl and betty-doc.pl
- You allowed to use a maximum of one global variable
- No more than 5 functions per file
- You are allowed to use the C standard library
- The prototypes of all your functions should be included in your header file called monty.h
- Don’t forget to push your header file
- All your header files should be include guarded
- You are expected to do the tasks in the order shown in the project
## Compilation & Output
## Your code will be compiled this way:
$ gcc -Wall -Werror -Wextra -pedantic -std=c89 *.c -o monty
Any output must be printed on stdout
Any error message must be printed on stderr
## Tests
We strongly encourage you to work all together on a set of tests## The Monty language
Monty 0.98 is a scripting language that is first compiled into Monty byte codes (Just like Python). It relies on a unique stack, with specific instructions to manipulate it. The goal of this project is to create an interpreter for Monty ByteCodes files.
## Mandatory tasks
## 0. push, pall
mandatory
Implement the push and pall opcodes.The push opcode
The opcode push pushes an element to the stack.
Usage: push
where is an integer
if is not an integer or if there is no argument given to push, print the error message L: usage: push integer, followed by a new line, and exit with the status EXIT_FAILURE
where is the line number in the file
You won’t have to deal with overflows. Use the atoi function
The pall opcodeThe opcode pall prints all the values on the stack, starting from the top of the stack.
Usage pall
Format: see example
If the stack is empty, don’t print anything
push 1$
push 2$
push 3$
pall$3
2
1
## 1. pint
mandatory
Implement the pint opcode.The pint opcode
The opcode pint prints the value at the top of the stack, followed by a new line.
Usage: pint
If the stack is empty, print the error message L: can't pint, stack empty, followed by a new line, and exit with the status EXIT_FAILUREpush 1
pint
push 2
pint
push 3
pint1
2
3
## 2. pop
mandatory
Implement the pop opcode.The pop opcode
The opcode pop removes the top element of the stack.
Usage: pop
If the stack is empty, print the error message L: can't pop an empty stack, followed by a new line, and exit with the status EXIT_FAILUREpush 1
push 2
push 3
pall
pop
pall
pop
pall
pop
pall3
2
1
2
1
1
## 3. swap
mandatory
Implement the swap opcode.The swap opcode
The opcode swap swaps the top two elements of the stack.
Usage: swap
If the stack contains less than two elements, print the error message L: can't swap, stack too short, followed by a new line, and exit with the status EXIT_FAILUREpush 1
push 2
push 3
pall
swap
pall3
2
1
2
3
## 4. add
mandatory
Implement the add opcode.The add opcode
The opcode add adds the top two elements of the stack.
Usage: add
If the stack contains less than two elements, print the error message L: can't add, stack too short, followed by a new line, and exit with the status EXIT_FAILURE
The result is stored in the second top element of the stack, and the top element is removed, so that at the end:
The top element of the stack contains the result
The stack is one element shorterpush 1
push 2
push 3
pall
add
pall3
2
1
5
1
## 5. nop
mandatory
Implement the nop opcode.The nop opcode
The opcode nop doesn’t do anything.
Usage: nop
## AUTHORS:
Brendon JejePaida Gwetsai
![AFAFAFS](https://happycoding.io/tutorials/html/images/rainbow-logo-2.png)