99 karma · joined Aug 1, 2018 (8y ago) · 34 submissions
comment 1y ago · link · parent
You probably noticed, but it should become a thing in RFC 3591: https://github.com/rust-lang/rust/issues/134691
So it does kind of work on current nightly:
#![feature(import_trait_associated_functions)]
use std::iter::Iterator::{filter, map, collect};
fn get_ids2(data: Vec<Widget>) -> Vec<Id> {
collect(map(filter(Vec::into_iter(data), |w| w.alive), |w| w.id))
}
fn get_ids3(data: impl Iterator<Item = Widget>) -> Vec<Id> {
collect(map(filter(data, |w| w.alive), |w| w.id))
}8.
Eyra Does the Impossible(blog.sunfishcode.online ↗)
3 points · by higherhalf · 3y ago · 1 comment
comment 3y ago · link · parent
global _start
_start:
jmp next
string:
db `Hello World!\n`
len: equ $ - string
next:
mov ecx, string
mov edx, len
mov ebx, 1
mov eax, 4
int 80h
mov ebx, 0
mov eax, 1
int 80h
For NASM, it can also be put into a macro, for example printing to video memory at 0xb8000: %macro print 1
mov ecx, %%loop_start - %%strdata
mov eax, 0x0700
jmp %%loop_start
%%strdata: db %1
%%loop_start:
mov al, [%%strdata + ecx - 1]
mov [0xb8000 + ecx * 2 - 2], ax
loop %%loop_start
%endmacrocomment 3y ago · link · parent
AMD processors have Upper Address Ignore (UAI) with 7 bits of ancillary data, for Intel there is Linear Address Masking (LAM) with 6 or 15 bits [1]. The latter has made it into Linux after some initial resistance [2].
[1]: https://lwn.net/Articles/888914
[2]: https://www.phoronix.com/news/Intel-LAM-Merged-Linux-6.4
comment 3y ago · link · parent
> In zig you _can_ actually start with a c codebase and rewrite it file by file in zig and you _can_ include c headers in your zig files verbatim. Both of these are not possible in rust.
You can. Either via FFI and bindgen-ing headers, or by using c2rust. The latter is not just a toy ambitious project, but actually a very impressive piece of engineering and does produce a result where you can transpile a project or file and start rewriting file-by-file or function-by-function.
comment 3y ago · link · parent
comment 3y ago · link · parent
[1]: https://www.fasterthan.life/blog/2017/7/11/i-am-graphics-and...
comment 3y ago · link · parent
There's also Kerla: https://github.com/nuta/kerla
comment 4y ago · link · parent
As you're likely aware, Rust for embedded sucks when there's no HAL, but should be pretty pleasant otherwise. Have you looked into the cortex-a[1] crate?
Some unnecessary instructions could also be a part of an ongoing optimization effort[2][3].
[1]: https://github.com/rust-embedded/cortex-a
[2]: https://old.reddit.com/r/rust/comments/yn6105/optimization_o...
comment 5y ago · link · parent
No. When I started the project I was expecting to just read data into the ELF structs, in style of C. (Un)fortunately, it's not possible to do safely, so I started looking into crates to do that, and was stumbling upon data deserialization ones. In particular, the first attempt was in nom. In hindsight, that wasn't particularly smart, and specific object-file-parsing ones would be better. I don't regret implementing reading manually, despite it looking pretty ugly, because attending to NIH syndrome is fun.
> Speaking of visualizing virtual memory, one of the things that I haven't seen a nice prior tool for is breaking down the memory map of a process on a per-section basis
That is planned. It's noted in readme, and in issue #3 I go over how it can look like[1].
[1]: https://github.com/ruslashev/elfcat/issues/3#issuecomment-86...
comment 5y ago · link · parent
Yes, this is a bug. Thanks for reporting it to the issue tracker.
> Also, I wish the arrow heads did not opaquely overlap the numbers. Adding opacity="0.3" to the svg tag fixes this for me.
Will put to toggle-able options. The arrows really hinder comprehension, perhaps arrowheads could be made smaller too.