Compare commits
No commits in common. "main" and "v0.3.0" have entirely different histories.
@ -1,6 +1,7 @@
|
|||||||
// This example contains information adapted from the MSPGCC project's documentation.
|
// This example contains information adapted from the MSPGCC project's documentation.
|
||||||
// As such, it is licensed under the GPL, to the extent that such a thing is possible.
|
// As such, it is licensed under the GPL, to the extent that such a thing is possible.
|
||||||
// https://mspgcc.sourceforge.net/manual/ln16.html
|
// https://mspgcc.sourceforge.net/manual/ln16.html
|
||||||
|
#![feature(decl_macro)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!")
|
println!("Hello, world!")
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
//! Helper library for msp430-asm
|
//! Helper library for msp430-asm
|
||||||
|
#![feature(decl_macro)]
|
||||||
pub mod split_twice {
|
pub mod split_twice {
|
||||||
/// Slices a collection into a beginning, middle, and end, based on two unordered indices
|
/// Slices a collection into a beginning, middle, and end, based on two unordered indices
|
||||||
pub trait SplitTwice<'t> {
|
pub trait SplitTwice<'t> {
|
||||||
@ -62,50 +63,29 @@ pub mod cursor {
|
|||||||
use std::fmt::{Arguments, Display};
|
use std::fmt::{Arguments, Display};
|
||||||
|
|
||||||
/// Moves to the {line}th previous line
|
/// Moves to the {line}th previous line
|
||||||
#[macro_export]
|
pub macro previous($line:literal) {
|
||||||
macro_rules! previous {
|
|
||||||
($line:literal) => {
|
|
||||||
csi!("{}F", $line)
|
csi!("{}F", $line)
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Injects a Command Sequence Introducer
|
/// Injects a Command Sequence Introducer
|
||||||
#[macro_export]
|
pub macro csi($($t:tt)*) {
|
||||||
macro_rules! csi {
|
|
||||||
($($t:tt)*) => {
|
|
||||||
format_args!("\x1b[{}", format_args!($($t)*))
|
format_args!("\x1b[{}", format_args!($($t)*))
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Formats the args with a foreground [Color]
|
/// Formats the args with a foreground [Color]
|
||||||
#[macro_export]
|
pub macro fg($fg:expr, $($t:tt)*) {
|
||||||
macro_rules! fg {
|
|
||||||
($fg:expr, $($t:tt)*) => {
|
|
||||||
Colorized::new(Some($fg), None, format_args!($($t)*))
|
Colorized::new(Some($fg), None, format_args!($($t)*))
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Formats the args with a background [Color]
|
/// Formats the args with a background [Color]
|
||||||
#[macro_export]
|
pub macro bg($bg:expr, $(t:tt)*) {
|
||||||
macro_rules! bg {
|
|
||||||
($bg:expr, $(t:tt)*) => {
|
|
||||||
Colorized::new(None, Some($bg), format_args!($($t)*))
|
Colorized::new(None, Some($bg), format_args!($($t)*))
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Formats the args with both a foreground and background [Color]
|
/// Formats the args with both a foreground and background [Color]
|
||||||
#[macro_export]
|
pub macro color($fg:expr, $bg:expr, $($t:tt)*) {
|
||||||
macro_rules! color {
|
|
||||||
($fg:expr, $bg:expr, $($t:tt)*) => {
|
|
||||||
Colorized::new(Some($fg), Some($bg), format_args!($($t)*))
|
Colorized::new(Some($fg), Some($bg), format_args!($($t)*))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub use bg;
|
|
||||||
pub use color;
|
|
||||||
pub use csi;
|
|
||||||
pub use fg;
|
|
||||||
pub use previous;
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub enum Color {
|
pub enum Color {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// © 2023-2024 John Breaux
|
// © 2023-2024 John Breaux
|
||||||
//See LICENSE.md for license
|
//See LICENSE.md for license
|
||||||
//! Simple frontend for the assembler
|
//! Simple frontend for the assembler
|
||||||
|
#![feature(decl_macro)]
|
||||||
use argp::parse_args_or_exit;
|
use argp::parse_args_or_exit;
|
||||||
use libmsp430::{
|
use libmsp430::{
|
||||||
assembler::Assemble,
|
assembler::Assemble,
|
||||||
@ -65,16 +66,14 @@ mod repl {
|
|||||||
use std::io::{stderr, Write};
|
use std::io::{stderr, Write};
|
||||||
|
|
||||||
/// Formats the line number
|
/// Formats the line number
|
||||||
macro_rules! linenr {
|
macro linenr($n: expr) {
|
||||||
($n: expr) => {
|
|
||||||
format_args!("{:4}: ", $n)
|
format_args!("{:4}: ", $n)
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [println], but without the newline
|
/// [println], but without the newline
|
||||||
macro_rules! printfl {($($x: expr),+) => {
|
macro printfl ($($x: expr),+) {
|
||||||
{print!($($x),+); let _ = ::std::io::stdout().flush();}
|
{print!($($x),+); let _ = ::std::io::stdout().flush();}
|
||||||
}}
|
}
|
||||||
|
|
||||||
/// Runs the read-evaluate-print loop
|
/// Runs the read-evaluate-print loop
|
||||||
pub fn repl(buf: &mut String) -> Result<(), Box<dyn Error>> {
|
pub fn repl(buf: &mut String) -> Result<(), Box<dyn Error>> {
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
; © 2023-2024 John Breaux
|
; © 2023-2024 John Breaux
|
||||||
; Comtains spoilers for Microcorruption Halifax! Be warned!
|
; Comtains spoilers for Microcorruption Halifax! Be warned!
|
||||||
|
; just hash the first 0x140 B and stick them in memory
|
||||||
|
|
||||||
|
|
||||||
const:
|
const:
|
||||||
.define msize 0x1 ; length of each hash in bytes
|
.define msize 0x1 ; length of each hash in bytes
|
||||||
.define hsize 0x3 ; bytes kept per hash (only needs to be 3 to determine 1 byte of sram)
|
.define hsize 0x3 ; bytes kept per hash (only needs to be 3 to determine 1 byte of sram)
|
||||||
.define sr_len 0x140 ; number of bytes in sram to dump
|
.define sr_len 0x140 ; number of bytes in sram to dump
|
||||||
|
.define ha_len 0x3c0 ; number of bytes in hash array (hsize * sr_len)
|
||||||
.define haddr 0x7000 ; address of the big hash array
|
.define haddr 0x7000 ; address of the big hash array
|
||||||
.define iaddr 0x8000 ; address of the sram input buffer
|
.define iaddr 0x8000 ; address of the sram input buffer
|
||||||
.define kaddr 0x9000 ; address of the key buffer
|
.define kaddr 0x9000 ; address of the key buffer
|
||||||
@ -33,10 +35,10 @@ get_sram_hashes:
|
|||||||
mov #haddr, r13 ; set destination to 0x8000
|
mov #haddr, r13 ; set destination to 0x8000
|
||||||
sr_loop:
|
sr_loop:
|
||||||
mov r11, r15 ; mov addr r15
|
mov r11, r15 ; mov addr r15
|
||||||
call sha256_internal ; sha256_internal (i, msize, haddr + i * hsize)
|
call sha256_internal ; <sha256_internal>
|
||||||
add #hsize, r13 ; keep 3 bytes of the output
|
add #hsize, r13 ; keep 3 bytes of the output
|
||||||
inc r11 ; inc r11
|
inc r11 ; inc r11
|
||||||
cmp #sr_len, r11 ; do that sram_len times
|
cmp #sr_len, r11 ; do that 0x1000 times
|
||||||
jnc sr_loop
|
jnc sr_loop
|
||||||
|
|
||||||
print_hex:
|
print_hex:
|
||||||
@ -51,21 +53,21 @@ print_hex:
|
|||||||
clrc
|
clrc
|
||||||
and #0xf, r14
|
and #0xf, r14
|
||||||
mov.b HEX_LUT(r15), r15
|
mov.b HEX_LUT(r15), r15
|
||||||
call putchar ; putchar (HEX_LUT[haddr[i] >> 4])
|
call putchar ; <putchar>
|
||||||
mov.b HEX_LUT(r14), r15
|
mov.b HEX_LUT(r14), r15
|
||||||
call putchar ; putchar (HEX_LUT[haddr[i] & 0xf])
|
call putchar ; <putchar>
|
||||||
inc r11
|
inc r11 ; inc r11
|
||||||
cmp #sr_len * hsize, r11 ; do that sram_length * hash_size times
|
cmp #ha_len, r11 ; do that sram_length*3 times
|
||||||
jnc ph_loop
|
jnc ph_loop
|
||||||
|
|
||||||
mov.b #'\n', r15 ; '\n'
|
mov.b #0xa, r15 ; '\n'
|
||||||
call putchar ; putchar ('\n')
|
call #0x4578 ; putchar ('\n')
|
||||||
|
|
||||||
|
|
||||||
take_input:
|
take_input:
|
||||||
mov #sr_len, r14
|
mov #sr_len, r14
|
||||||
mov #iaddr, r15
|
mov #iaddr, r15
|
||||||
call getsn ; getsn (iaddr, sr_len)
|
call getsn ; <getsn>
|
||||||
|
|
||||||
check_all_passwords:
|
check_all_passwords:
|
||||||
;for i in 0..sr_len:
|
;for i in 0..sr_len:
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
pub mod token;
|
pub mod token;
|
||||||
|
|
||||||
use self::token::*;
|
use self::token::{Special, TokenKind, *};
|
||||||
use crate::span::Span;
|
use crate::span::Span;
|
||||||
use std::{
|
use std::{
|
||||||
iter::Peekable,
|
iter::Peekable,
|
||||||
|
@ -173,10 +173,6 @@ impl<'t> Parser<'t> {
|
|||||||
self.take();
|
self.take();
|
||||||
Expr::Number(n)
|
Expr::Number(n)
|
||||||
}
|
}
|
||||||
Kind::Char(c) => {
|
|
||||||
self.take();
|
|
||||||
Expr::Number(c as _)
|
|
||||||
}
|
|
||||||
Kind::Identifier => {
|
Kind::Identifier => {
|
||||||
self.take();
|
self.take();
|
||||||
Expr::Ident(lexeme)
|
Expr::Ident(lexeme)
|
||||||
|
@ -645,12 +645,13 @@ pub mod canonical {
|
|||||||
Expr::Number(tail)
|
Expr::Number(tail)
|
||||||
}
|
}
|
||||||
Expr::Binary(head, tails) => {
|
Expr::Binary(head, tails) => {
|
||||||
let mut tails = tails.into_iter().map(|(op, tail)| (op, tail.to_canonical()));
|
|
||||||
let mut head = match head.to_canonical() {
|
let mut head = match head.to_canonical() {
|
||||||
Expr::Number(n) => n,
|
Expr::Number(n) => n,
|
||||||
head => return Expr::Binary(head.into(), tails.collect()),
|
head => return Expr::Binary(head.into(), tails),
|
||||||
};
|
};
|
||||||
|
let mut tails = tails.into_iter();
|
||||||
for (op, tail) in &mut tails {
|
for (op, tail) in &mut tails {
|
||||||
|
let tail = tail.to_canonical();
|
||||||
// If the canonical tail isn't a number, rebuild and return
|
// If the canonical tail isn't a number, rebuild and return
|
||||||
let Expr::Number(tail) = tail else {
|
let Expr::Number(tail) = tail else {
|
||||||
return Expr::Binary(
|
return Expr::Binary(
|
||||||
|
Loading…
Reference in New Issue
Block a user