aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c49
1 files changed, 33 insertions, 16 deletions
diff --git a/src/main.c b/src/main.c
index 21c8e0e..e10c8f0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -517,12 +517,38 @@ init_uxn() {
517 // uxn_boot(u, uxn_ram, uxn_dei, uxn_deo); 517 // uxn_boot(u, uxn_ram, uxn_dei, uxn_deo);
518 518
519 // Copy rom to VM. 519 // Copy rom to VM.
520 u8 uxn_rom[] = { 520 u8 uxn_rom[32] = {
521 // Hello world (h) 521 // Hello world (h)
522 // 0x80, 0x68, 0x80, 0x18, 0x17, 522 // 0x80, 0x68, 0x80, 0x18, 0x17,
523 // 523 //
524 // ADD test 524 // ADD test
525 0x80, 0x04, 0x80, 0x03, 0x80, 0x02, 0x80, 0x01, 0x18 525 // 0x80, 0x04, 0x80, 0x03, 0x80, 0x02, 0x80, 0x01, 0x18, 0x18
526 // SUB test
527 // 0x80, 0x04, 0x80, 0x03, 0x80, 0x02, 0x80, 0x01, 0x19, 0x19, 0x19
528 // LIT2 04 03 LIT2 02 01 ADD ADD ADD BRK
529 // 0xa0, 0x04, 0x03,
530 // 0xa0, 0x04, 0x03, 0xa0, 0x02, 0x01,
531 // 0xa0, 0x04, 0x03, 0xa0, 0x02, 0x01, 0x18, 0x18, 0x00
532 // #0004 #0008 ADD
533 // 0xa0, 0x00, 0x04, 0xa0, 0x00, 0x08, 0x18,
534 // #0004 #0008 ADD2
535 0x80, 0xFF, 0xff,
536 0xa0, 0x00, 0x08, 0xa0, 0x00, 0x04, 0x38,
537 // 0xa0, 0x00, 0x08, 0xa0, 0x00, 0x03, 0x39,
538 // 0xa0, 0x00, 0x01, 0x38,
539 //
540 // 0x80, 0xFF, 0xff,
541 // 0xa0, 0xba, 0xdd,
542 // 0xa0, 0x10, 0xde,
543 // 0xa0, 0xfe, 0xed,
544 // 0xa0, 0xde, 0xaf,
545 // 0xa0, 0xba, 0xdd,
546 // 0xa0, 0x10, 0xde,
547 // 0xa0, 0xfe, 0xed,
548 // 0xa0, 0xde, 0xaf,
549 //
550 // #0008 #0003 SUB2
551 // 0xa0, 0x00, 0x08, 0xa0, 0x00, 0x03,
526 }; 552 };
527 memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); 553 memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom));
528} 554}
@@ -715,7 +741,6 @@ handle_input(Uxn *u) {
715 741
716#define STACK_SIZE 16 742#define STACK_SIZE 16
717u8 stack[STACK_SIZE] = {0}; 743u8 stack[STACK_SIZE] = {0};
718extern void uxn_init_asm(void);
719extern void uxn_eval_asm(u16 pc); 744extern void uxn_eval_asm(u16 pc);
720 745
721// TODO: This should be on the IWRAM for maximum speed, as these are operations 746// TODO: This should be on the IWRAM for maximum speed, as these are operations
@@ -766,29 +791,21 @@ main(void) {
766 rst[i] = 0; 791 rst[i] = 0;
767 io_ports[i] = 0; 792 io_ports[i] = 0;
768 } 793 }
769 uxn_init_asm();
770 794
771 txt_printf("ROM\n\n"); 795 txt_printf("ROM\n\n");
772 for (size_t i = 0; i < 8; i++) { 796 for (size_t i = 0; i < 32; i++) {
773 txt_printf("%02x ", uxn_ram[i + PAGE_PROGRAM]); 797 if (i % 8 == 0) {
774 }
775 txt_printf("\n\n");
776
777 txt_printf("STACK (BEFORE)\n");
778 txt_printf("PTR: %d\n", wst_ptr - (uintptr_t)wst);
779 for (size_t i = 0; i < STACK_SIZE; i++) {
780 if (i % 4 == 0) {
781 txt_printf("\n"); 798 txt_printf("\n");
782 } 799 }
783 txt_printf("%02x ", wst[i]); 800 txt_printf("%02x ", uxn_ram[i + PAGE_PROGRAM]);
784 } 801 }
785 txt_printf("\n\n"); 802 txt_printf("\n\n");
786 803
787 uxn_eval_asm(PAGE_PROGRAM); 804 uxn_eval_asm(PAGE_PROGRAM);
788 txt_printf("STACK (AFTER)\n"); 805 txt_printf("STACK\n");
789 txt_printf("PTR: %d\n", wst_ptr - (uintptr_t)wst); 806 txt_printf("PTR: %d\n", wst_ptr - (uintptr_t)wst);
790 for (size_t i = 0; i < STACK_SIZE; i++) { 807 for (size_t i = 0; i < STACK_SIZE; i++) {
791 if (i % 4 == 0) { 808 if (i % 8 == 0) {
792 txt_printf("\n"); 809 txt_printf("\n");
793 } 810 }
794 txt_printf("%02x ", wst[i]); 811 txt_printf("%02x ", wst[i]);