You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I was trying to make the phrases more legible than hex numbers.
But I ran into a snag I think- you can't use consts to build a phrase?
Check this out- I build a phrase with hex digits and build the same
phrase with constants. They don't display the same thing.
It would be nice if this was supported. What do you think?
:const iR 0x0A
:const iE 0x41
:const iA 0x32
:const iD 0x0C
:const iY 0x71
: readyConst
iR iE iA iD iY
: draw-text
v1 := 2 # x
#v2 := 1 # y
v3 := 0 # byte
# v4 contains length
loop
: text-addr i := 0 # draw phrase modifies to phrase addr
i += v3 # inc to next char in phrase
load v0 # lad char offest into v0 from i
i := font # now make i beginging of font
i += v0 # add char offset. i is pointing to sprite.
sprite v1 v2 5
v1 += 5
if v1 == 62 then v2 += 6
if v1 == 62 then v1 := 2
v3 += 1
if v3 != v4 then
again
;
: draw-ready-literal
:unpack 0xA readyLiteral # Get address of phrase into v1 v2
i := text-addr # load addrss of loop init in draw-text
save v1 # save v1/v2 into loop init code
v4 := 5 # load count of chars
draw-text
;
: draw-ready-const
:unpack 0xA readyConst
i := text-addr
save v1
v4 := 5
draw-text
;
: wait
v0 := 128
delay := v0
loop
v0 := delay
if v0 != 0 then
again
;
I replied to your email, but just for the purposes of keeping things documented I'll summarize here:
Constants declared with :const are treated exactly like labels when used outside of instructions. The difference between the patterns here is that the constant references are compiled into calls to subroutines. This functionality is already used for building jump tables and by the disassembler for various reasons. It would be possible to alter the semantics of :const to get the desired behavior, but I think a better resolution would be to create a new construct with this type of purpose in mind.
One proposal is the addition of a :macro operative which would allow you to assign a name to a pattern of bytes which would be inlined wherever the name of the macro was used. A particularly nice aspect of this system is it could serve to simplify some parts of the existing assembler and make it easier to experiment with custom extended instruction sets. I'll give the precise syntax and semantics some thought and update this issue when I come to a final decision.
So I was trying to make the phrases more legible than hex numbers.
But I ran into a snag I think- you can't use consts to build a phrase?
Check this out- I build a phrase with hex digits and build the same
phrase with constants. They don't display the same thing.
It would be nice if this was supported. What do you think?
: font
0x20 0x20 0x20 0x00 0x20 0xF0 0x10 0x70 0x00 0x40 0xE0 0x90 0xE0 0x90 0x90 0x90
0xE0 0x90 0xE0 0x90 0xE0 0x80 0x80 0xD0 0xB0 0xB0 0x90 0x90 0x90 0x90 0x60 0x60
0x90 0x90 0x90 0x60 0x90 0xD0 0xB0 0x90 0x90 0x90 0x50 0x20 0x40 0x00 0x00 0x00
0x00 0x00 0x60 0x90 0xF0 0x90 0x90 0xF0 0x90 0x90 0xF0 0x80 0xE0 0x80 0x80 0x80
0x80 0xF0 0x80 0xE0 0x80 0xF0 0x40 0x40 0x40 0xF0 0x20 0x40 0x80 0xF0 0x20 0x20
0x20 0xC0 0x60 0x90 0x80 0x90 0x60 0x90 0x90 0xB0 0x70 0x80 0xB0 0x90 0x70 0x80
0x60 0x10 0xE0 0x90 0xA0 0xC0 0xA0 0x90 0x90 0xB0 0xB0 0xD0 0xF0 0x40 0x40 0x40
0x40 0x90 0x90 0x70 0x10 0xE0
: readyLiteral
0x0A 0x41 0x32 0x0C 0x71
:const iR 0x0A
:const iE 0x41
:const iA 0x32
:const iD 0x0C
:const iY 0x71
: readyConst
iR iE iA iD iY
: draw-text
v1 := 2 # x
#v2 := 1 # y
v3 := 0 # byte
# v4 contains length
loop
: text-addr i := 0 # draw phrase modifies to phrase addr
i += v3 # inc to next char in phrase
load v0 # lad char offest into v0 from i
i := font # now make i beginging of font
i += v0 # add char offset. i is pointing to sprite.
;
: draw-ready-literal
:unpack 0xA readyLiteral # Get address of phrase into v1 v2
i := text-addr # load addrss of loop init in draw-text
save v1 # save v1/v2 into loop init code
v4 := 5 # load count of chars
draw-text
;
: draw-ready-const
:unpack 0xA readyConst
i := text-addr
save v1
v4 := 5
draw-text
;
: wait
v0 := 128
delay := v0
loop
v0 := delay
if v0 != 0 then
again
;
: stop
: here jump here
: main
v2 := 1
draw-ready-literal
v2 := 10
draw-ready-const
stop
The text was updated successfully, but these errors were encountered: