uxn
I tried putting the string in the zero page to remove the BRK, but uxnasm didn't seem to understand string literals there?
uxn
@tty last post i promise:
if we allow unclean exit i can do it in 24 with:
|0100
LIT2 0a 'd LIT2 'l 'r LIT2 'o 'w
LIT2 20 'o LIT2 'l 'l LIT2 'e 'H
@loop #18 DEO ,loop JMP
uxn
@d6 haha, I love this!
Dropping the newline requirement (mine didn't have this) yours is actually 23
uxn
@d6 btw if we're ok with unclean exit now, mine /wo the BRK opcode is now also 23 😈
uxn
@d6 do you know the reason for this?
uxn
@tty I think the idea is that most ROMs don’t use most of the zero page so you save around 100 bytes per ROM to omit it
uxn
@d6 That makes sense, but it seems feasible for uxnasm to detect when you ARE trying to store data there, no?
uxn
@tty @d6 young uxn had the zero-page part of the rom, then we later moved to having an address at the start of the rom that indicated where the first vector was, then the concept of devices became clearer and we standardized all roms to start at 0x0100 since there wasn't that many roms that needed prefills anyways.
It has been like that since.
uxn
@tty i think what @neauoire means is that the rom consists of a bunch of bytes and the emulator needs to know where the ROM bytes go into memory. currently the emulator just loads the ROM starting at 0x100, so the first byte in the ROM goes at 0x100, the second at 0x101 and so on. so if you wanted to optionally include a zero pad you'd need some kind of header or metadata to let the emulator know what the bytes mean.
uxn
@tty @d6 in calc, there is no data written to the zero-page
https://git.sr.ht/~rabbits/uxn/tree/main/item/projects/software/calc.tal#L10
It's assigning labels to addresses, so you have some values for .input, .stack, etc.
The devices are the same thing, it's not really doing anything special for devices, it's just assigning numbers between 0-256 to some label.
uxn
@tty @d6 Oh XD haha, okay I've confused everything. I thought you meant that calc was storing some sort of data on boot, which it isn't but it has a lot of zero-page addresses for the runtime.
So yes, zero-page is 0x000-0x0100. Nothing special happens when you write to the zero-page.
Most applications will store things that change a lot, or that you need quick access to.
uxn
uxn
So let's say we did allow to write initial values in the zero-page. For example, in the calc, you could prefill the stack with values if you liked.
We'd instead load the rom at 0x0000 in memory, instead of 0x0100. For hello world, you could store the string in the zero-page, and the program would still start at 0x0100, the rom would be about 120-ish bytes long.
uxn
@neauoire Is the problem that uxnemu assumes that byte 0 in the rom is address 0x0100?
uxn
@tty It's a convention that came from iteration, but it's not a technical issue.
We have 3 options, that I know of, where you either
a) load the rom at 0x0000, making the smallest program at least 100 bytes long.
b) load the rom at 0x0100
c) add a sort of header to roms that indicates the various possible mappings of where a rom starts/ends, etc.. Like on the famicom.
uxn
@neauoire Got it. I was interpreting it as a technical limitation, which was confusing me. Thanks for explaining :)
uxn
@tty np :) We went through all 3 options over time, in the end I chose the option that had the least side-effects.
uxn
@tty a ROM can't represent initial data in the zero page -- you have to actually initialize it by hand.