Trim instruction subset

This commit is contained in:
Hazem Krimi
2024-03-14 18:40:13 +01:00
parent fd8e48e904
commit aa9e2d905b
2 changed files with 48 additions and 3 deletions
+45
View File
@@ -0,0 +1,45 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'hack-assembler'",
"cargo": {
"args": [
"build",
"--bin=hack-assembler",
"--package=hack-assembler"
],
"filter": {
"name": "hack-assembler",
"kind": "bin"
}
},
"args": ["../rect/RectL.asm"],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'hack-assembler'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=hack-assembler",
"--package=hack-assembler"
],
"filter": {
"name": "hack-assembler",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
+3 -3
View File
@@ -5,7 +5,7 @@ pub fn decimal_to_fifteen_bits_binary(decimal: &i32) -> String {
pub fn translate_dest(dest: &String) -> String {
let cloned = dest.clone();
match cloned.as_str() {
match cloned.as_str().trim() {
"M" => "001",
"D" => "010",
"MD" => "011",
@@ -21,7 +21,7 @@ pub fn translate_dest(dest: &String) -> String {
pub fn translate_jump(jump: &String) -> String {
let cloned = jump.clone();
match cloned.as_str() {
match cloned.as_str().trim() {
"JGT" => "001",
"JEQ" => "010",
"JGE" => "011",
@@ -37,7 +37,7 @@ pub fn translate_jump(jump: &String) -> String {
pub fn translate_comp(comp: &String) -> String {
let cloned = comp.clone();
match cloned.as_str() {
match cloned.as_str().trim() {
"0" => "0101010",
"1" => "0111111",
"-1" => "0111010",