5 ms·
RAM ADDR ________ ---- |----***-| ---* |---*****| --*- |--*-*--*| --** |---****-| -*-- |-*------| -*-* |--------| -**- |----
by daveloyall 11y ago
RAM
ADDR ________
---- |----***-|
---* |---*****|
--*- |--*-*--*|
--** |---****-|
-*-- |-*------|
-*-* |--------|
-**- |--------|
-*** |--------|
*--- |--------|
*--* |-------*|
*-*- |--------|
*-** |--------|
**-- |--------|
**-* |--------|
***- |--------|
- deleted 11y ago[deleted]
- deleted 11y ago[deleted]
- nsajko 11y agoRAM ADDR ________ ---- |----***-| ---* |---*****| --*- |--*-**-*| --** |---****-| -*-- |-*-*-**-| -*-* |-*------| -**- |----**--| -*** |---****-| *--- |--------| *--* |--------| *-*- |--------| *-** |--------| **-- |--------| **-* |-------*| ***- |--------| This should get the counter back to 0 after it gets to 255 :)
- daveloyall 11y agohah! I just implemented that locally. Here's what I came up with... ________ |----***-| |-*-*-**-| |---*****| |--*-*--*| |---****-| |-*------| |----**--| |---****-| |-*------| |-------*| As you can see, it's pretty much the same, except in mine, the conditional is earlier, and I moved the initial 1 further up... Which required an additional jump?? ...I'd dig deeper but I'm eager to review this other comment, too!
- ketralnis 11y agoYou need the additional jump because he forgot his jump :) His doesn't actually reset on 255. It prints 254 and then stops. Here is his program commented: RAM AD PC ADDR ________ _ _ ---- |----***-|-|*| ; read in SCRATCH (starts at 0) ---* |---*****|-|-| ; write it to OUTPUT --*- |--*-**-*|-|-| ; add ONE --** |---****-|-|-| ; write to SCRATCH -*-- |-*-*-**-|-|-| ; IF MAX, GOTO LBL_RESET -*-* |-*------|-|-| ; ELSE, start over -**- |----**--|-|-| ; LBL_RESET: read in ZERO -*** |---****-|-|-| ; write the ZERO to SCRATCH *--- |--------|-|-| ; fall off the world (I think this is where is missing jump is) *--* |--------|-|-| *-*- |--------|-|-| *-** |--------|-|-| **-- |--------|-|-| ; ZERO (r/o literal) **-* |-------*|-|-| ; ONE (r/o literal) ***- |--------|-|-| ; SCRATCH (r/w) **** | OUTPUT |-|-| If I change his "fall off the world" to a "start over" instruction (-*------) then it works fine
- nsajko 11y agoThank you :)
- ketralnis 11y agoYou can do it in one fewer clock cycle per loop by just using the register instead of the extra scratch memory space :) (I also reset the loop at the end or it would be two fewer): RAM AD PC ADDR ________ _ _ ---- |---*****|-|*| ; OUTPUT the register ---* |-*-*-*--|-|-| ; IF MAX, goto LBL_RESET --*- |--*--**-|-|-| ; else add ONE to the register... --** |-*------|-|-| ; ...and start over. -*-- |-----***|-|-| ; LBL RESET: read in ZERO to the register... -*-* |-*------|-|-| ; ...and start over. -**- |-------*|-|-| ; ONE (r/o data) -*** |--------|-|-| ; ZERO (r/o data)
- daveloyall 11y agoOh! Yes, that's totally what registers are for, huh? :) Thank you.
- daveloyall 11y agoCan anybody make a https://en.wikipedia.org/wiki/Quine_%28computing%29 https://en.wikipedia.org/wiki/Quine_%28computing%29 ?
- ketralnis 11y agoThe straight forward way is a loop that reads in every byte and prints it. But you can only read from literal addresses; there's no instruction to read from the address in the register or to even read out the program counter. If you could control the initial register value to set it to , this would be a quine: RAM AD PC ADDR ________ _ _ ---- |---*****|-|*| ---* |---*****|-|-| --*- |---*****|-|-| --** |---*****|-|-| -*-- |---*****|-|-| -*-* |---*****|-|-| -**- |---*****|-|-| -*** |---*****|-|-| *--- |---*****|-|-| *--* |---*****|-|-| *-*- |---*****|-|-| *-** |---*****|-|-| **-- |---*****|-|-| **-* |---*****|-|-| ***- |---*****|-|-| **** | OUTPUT |-|-| ############ But since you can't, that instead prints out all zeroes. I don't have any other ideas :)
- daveloyall 11y agoDoes this provide any inspiration? RAM AD PC ADDR ________ _ _ ---- |-----*-*|-|*| ; read FOO ---* |---*----|-|-| ; write FOO to 0 (now points at BAR) --*- |---*****|-|-| ; print --** |-*------|-|-| ; back to the top! -*-- |-----*-*|-|-| ; BAR -*-* |-----*--|-|-| ; FOO -**- |--------|-|-| -*** |--------|-|-| *--- |--*---*-|-|-| ; a grand tradition in ROMs *--* |--------|-|-| ; though this isn't a ROM *-*- |----*---|-|-| ; anymore, is it? :) *-** |--------|-|-| **-- |--*---*-|-|-| **-* |---***--|-|-| ***- |--------|-|-|
- daveloyall 11y agoRAM AD PC ADDR ________ _ _ ---- |*--*----|-|*| ; high bit set? Instruction = READ ---* |-***----|-|-| --*- |--*-**-*|-|-| --** |---*----|-|-| -*-- |-*------|-|-| -*-* |--------|-|-| -**- |--------|-|-| -*** |--------|-|-| *--- |*-*-----|-|-| *--* |--------|-|-| *-*- |--------|-|-| *-** |--------|-|-| **-- |--------|-|-| **-* |*-------|-|-| ***- |--------|-|-| I had a basic idea of what I wanted to do here: to write instructions and subsequently execute them: self modifying code. That's as far as I've got, and I got there by twiddling bits, not by engineering...