Compile user code linked against the kernel stdlib. The kernel stdlib uses the "__kern_str_" string-label prefix so rodata labels never clash with user-code labels (which use "str_").
(user_src: &str)
| 437 | assert_eq!(uart, "PASS"); |
| 438 | assert_eq!(exit, Some(0)); |
| 439 | } |
| 440 | |
| 441 | #[test] |
| 442 | fn mem_cmp_detects_difference() { |
| 443 | // The first differing byte determines the sign. |
| 444 | let (uart, exit) = run_hll( |
| 445 | r#" |
| 446 | console := import("console") |
| 447 | mem := import("mem") |
| 448 | |
| 449 | main: () -> i32 { |
| 450 | a: u8[2] = [] |
| 451 | b: u8[2] = [] |
| 452 | a[0] = 65 |
| 453 | a[1] = 66 |
| 454 | b[0] = 65 |
| 455 | b[1] = 67 |
| 456 | a_ptr: u8* = &a[0] |
| 457 | b_ptr: u8* = &b[0] |
| 458 | result: i32 = mem.cmp(a_ptr, b_ptr, 2) |
| 459 | if result < 0 { |
| 460 | console.putchar(80) |
| 461 | console.putchar(65) |
| 462 | console.putchar(83) |
| 463 | console.putchar(83) |
| 464 | } |
| 465 | return 0 |
| 466 | } |
| 467 | "#, |
| 468 | ); |
| 469 | assert_eq!(uart, "PASS"); |
| 470 | assert_eq!(exit, Some(0)); |
| 471 | } |
| 472 | |
| 473 | // --- klog.hll --- |
| 474 | |
| 475 | #[test] |
| 476 | fn klog_ok_output() { |
| 477 | let (uart, exit) = run_with( |
| 478 | KLOG_SRC, |
| 479 | r#" |
| 480 | main: () -> i32 { |
| 481 | klog_ok("boot".ptr) |
| 482 | return 0 |
| 483 | } |