-
-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature request] Allow multiple instructions on one line with separators #805
Comments
If we just want to allow multiple instructions on one line, not labels, directives, etc, then it's a pretty simple change to the parser (using plain_directive : label
- | label cpu_command
+ | label cpu_commands
[...]
+cpu_commands : cpu_command
+ | cpu_command T_PERIOD cpu_commands
+; |
|
I would avoid : ldh a, [rSTAT] : and %11 : cp STATF_VBL : jr nz, :- For comparison: ; two colons
: ldh a, [rSTAT] :: and %11 :: cp STATF_VBL :: jr nz, :-
; two periods
: ldh a, [rSTAT] .. and %11 .. cp STATF_VBL .. jr nz, :-
; one period
: ldh a, [rSTAT] . and %11 . cp STATF_VBL . jr nz, :- On the other hand, periods might look weird with local labels: ; two periods
.wait_vbl: ldh a, [rSTAT] .. and %11 .. cp STATF_VBL .. jr nz, .wait_vbl
; one period
.wait_vbl: ldh a, [rSTAT] . and %11 . cp STATF_VBL . jr nz, .wait_vbl What are others' preferences? |
Hmm, periods should probably be avoided, as there was a suggested "current label scope" syntax using multiple periods. |
Then it's between ; using single colon
RestoreAllPP:
ld a, MON_PP : call GetPartyParamLocation
push hl
ld a, MON_MOVES : call GetPartyParamLocation
pop de
xor a : ld [wMenuCursorY], a : ld [wMonType], a
ld c, NUM_MOVES
.loop
ld a, [hli]
and a : ret z
push hl
push de : push bc
call GetMaxPPOfMove
pop bc : pop de
ld a, [de] : and PP_UP_MASK : ld b, a
ld a, [wTempPP] : add b : ld [de], a
inc de
ld hl, wMenuCursorY : inc [hl]
pop hl
dec c : jr nz, .loop
ret ; using double colon
RestoreAllPP:
ld a, MON_PP :: call GetPartyParamLocation
push hl
ld a, MON_MOVES :: call GetPartyParamLocation
pop de
xor a :: ld [wMenuCursorY], a :: ld [wMonType], a
ld c, NUM_MOVES
.loop
ld a, [hli]
and a :: ret z
push hl
push de :: push bc
call GetMaxPPOfMove
pop bc :: pop de
ld a, [de] :: and PP_UP_MASK :: ld b, a
ld a, [wTempPP] :: add b :: ld [de], a
inc de
ld hl, wMenuCursorY :: inc [hl]
pop hl
dec c :: jr nz, .loop
ret |
I just realized ; using dollar sign
RestoreAllPP:
ld a, MON_PP $ call GetPartyParamLocation
push hl
ld a, MON_MOVES $ call GetPartyParamLocation
pop de
xor a $ ld [wMenuCursorY], a $ ld [wMonType], a
ld c, NUM_MOVES
.loop
ld a, [hli]
and a $ ret z
push hl
push de $ push bc
call GetMaxPPOfMove
pop bc $ pop de
ld a, [de] $ and PP_UP_MASK $ ld b, a
ld a, [wTempPP] $ add b $ ld [de], a
inc de
ld hl, wMenuCursorY $ inc [hl]
pop hl
dec c $ jr nz, .loop
ret And for completeness, here's ; using pound sign
RestoreAllPP:
ld a, MON_PP # call GetPartyParamLocation
push hl
ld a, MON_MOVES # call GetPartyParamLocation
pop de
xor a # ld [wMenuCursorY], a # ld [wMonType], a
ld c, NUM_MOVES
.loop
ld a, [hli]
and a # ret z
push hl
push de # push bc
call GetMaxPPOfMove
pop bc # pop de
ld a, [de] # and PP_UP_MASK # ld b, a
ld a, [wTempPP] # add b # ld [de], a
inc de
ld hl, wMenuCursorY # inc [hl]
pop hl
dec c # jr nz, .loop
ret |
So, |
This comment was marked as off-topic.
This comment was marked as off-topic.
@ISSOtm The examples posted by sylvie (zlago) were selling me on |
In comments people often use "
/
" or "\
" to separate multiple instructions, like "ld a, [hli] \ ld h, [hl] \ ld l, a
". It could be possible to do this inrgbasm
as well: outside of string literals, backslash is only used for macro arguments and line continuations, and line continuations must be followed only by whitespace or comments before the newline.beginLineContinuation()
could change to return aT_NEWLINE
(or someT_FAKE_NEWLINE
if necessary) if it runs into a non-whitespace character, instead of printing an error. (Edit: theT_EOL
introduced by #716 might be appropriate here.)The text was updated successfully, but these errors were encountered: