Skip to content

Instantly share code, notes, and snippets.

@RickCarlino
Last active July 31, 2022 01:36
Show Gist options
  • Save RickCarlino/3770763398c7262e1eeec8e53731a4d9 to your computer and use it in GitHub Desktop.
Save RickCarlino/3770763398c7262e1eeec8e53731a4d9 to your computer and use it in GitHub Desktop.

Cell Alignment Issues?

{{
  #15 'COL-SIZE const
  '_______________%n,%n| 'double-column s:const
  '_______________%n|    'num-column    s:const
  '_______________%c|    'char-column   s:const
  :formatted s:format COL-SIZE s:right s:put ;
  :show-char (n-) dup c:-visible? [ drop $. ] if char-column formatted ;
  :show-num  (n-) num-column  formatted ;
  :left-side (aa-) @Base [ hex $| c:put swap double-column formatted ] dip !Base ;
  :right-side (-) nl ;
  :2dup 'ab 'abab reorder ;
---reveal---
  :mem:inspect (aa-) 2dup left-side mem:get &show-char &show-num bi right-side ;
  :cell+ (n-n) #4 * + ;
}}

Tests


#32 mem:alloc 'memory double:const
memory #0 cell+ #1 mem:set
memory #1 cell+ #2 mem:set
memory #2 cell+ #3 mem:set
memory #3 cell+ #4 mem:set

memory #0 cell+ mem:inspect
memory #1 cell+ mem:inspect
memory #2 cell+ mem:inspect
memory #3 cell+ mem:inspect
memory #4 cell+ mem:inspect
memory #5 cell+ mem:inspect
memory #6 cell+ mem:inspect
memory #7 cell+ mem:inspect
memory #8 cell+ mem:inspect
memory #9 cell+ mem:inspect

Output

Address Value (char) Value (dec)
5631,7A5E2490 . 1
5631,7A5E2494 . 2
5631,7A5E2498 . 3
5631,7A5E249C . 4
5631,7A5E24A0 . 0
5631,7A5E24A4 . 0
5631,7A5E24A8 . 0
5631,7A5E24AC . 0
5631,7A5E24B0 . 0
5631,7A5E24B4 . 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment