This repository has been archived by the owner on May 21, 2024. It is now read-only.
forked from boriel-basic/zxbasic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request boriel-basic#608 from boriel/fix/bad_optimization
fix: fix optimization for FOR loop
- Loading branch information
Showing
5 changed files
with
205 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
org 32768 | ||
.core.__START_PROGRAM: | ||
di | ||
push ix | ||
push iy | ||
exx | ||
push hl | ||
exx | ||
ld hl, 0 | ||
add hl, sp | ||
ld (.core.__CALL_BACK__), hl | ||
ei | ||
jp .core.__MAIN_PROGRAM__ | ||
.core.__CALL_BACK__: | ||
DEFW 0 | ||
.core.ZXBASIC_USER_DATA: | ||
; Defines USER DATA Length in bytes | ||
.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA | ||
.core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN | ||
.core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA | ||
.core.ZXBASIC_USER_DATA_END: | ||
.core.__MAIN_PROGRAM__: | ||
call _main | ||
ld hl, 0 | ||
ld b, h | ||
ld c, l | ||
.core.__END_PROGRAM: | ||
di | ||
ld hl, (.core.__CALL_BACK__) | ||
ld sp, hl | ||
exx | ||
pop hl | ||
pop iy | ||
pop ix | ||
exx | ||
ei | ||
ret | ||
_saludar: | ||
push ix | ||
ld ix, 0 | ||
add ix, sp | ||
ld l, (ix+4) | ||
ld h, (ix+5) | ||
inc hl | ||
_saludar__leave: | ||
ld sp, ix | ||
pop ix | ||
exx | ||
pop hl | ||
ex (sp), hl | ||
exx | ||
ret | ||
_main: | ||
push ix | ||
ld ix, 0 | ||
add ix, sp | ||
ld hl, 0 | ||
push hl | ||
ld (ix-2), 1 | ||
ld (ix-1), 0 | ||
jp .LABEL.__LABEL0 | ||
.LABEL.__LABEL3: | ||
ld l, (ix-2) | ||
ld h, (ix-1) | ||
push hl | ||
call _saludar | ||
ld l, (ix-2) | ||
ld h, (ix-1) | ||
inc hl | ||
ld (ix-2), l | ||
ld (ix-1), h | ||
.LABEL.__LABEL0: | ||
ld l, (ix-2) | ||
ld h, (ix-1) | ||
ex de, hl | ||
ld hl, 2 | ||
or a | ||
sbc hl, de | ||
jp nc, .LABEL.__LABEL3 | ||
_main__leave: | ||
ld sp, ix | ||
pop ix | ||
ret | ||
;; --- end of user code --- | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
main() | ||
|
||
function saludar(x as Uinteger) as Uinteger | ||
return x + 1 | ||
end function | ||
|
||
sub main() | ||
dim i, result as uinteger | ||
for i = 1 to 2 | ||
result = saludar(i) | ||
next | ||
end sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
org 32768 | ||
.core.__START_PROGRAM: | ||
di | ||
push ix | ||
push iy | ||
exx | ||
push hl | ||
exx | ||
ld hl, 0 | ||
add hl, sp | ||
ld (.core.__CALL_BACK__), hl | ||
ei | ||
jp .core.__MAIN_PROGRAM__ | ||
.core.__CALL_BACK__: | ||
DEFW 0 | ||
.core.ZXBASIC_USER_DATA: | ||
; Defines USER DATA Length in bytes | ||
.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA | ||
.core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN | ||
.core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA | ||
.core.ZXBASIC_USER_DATA_END: | ||
.core.__MAIN_PROGRAM__: | ||
call _main | ||
ld hl, 0 | ||
ld b, h | ||
ld c, l | ||
.core.__END_PROGRAM: | ||
di | ||
ld hl, (.core.__CALL_BACK__) | ||
ld sp, hl | ||
exx | ||
pop hl | ||
pop iy | ||
pop ix | ||
exx | ||
ei | ||
ret | ||
_saludar: | ||
push ix | ||
ld ix, 0 | ||
add ix, sp | ||
ld l, (ix+4) | ||
ld h, (ix+5) | ||
inc hl | ||
_saludar__leave: | ||
ld sp, ix | ||
pop ix | ||
exx | ||
pop hl | ||
ex (sp), hl | ||
exx | ||
ret | ||
_main: | ||
push ix | ||
ld ix, 0 | ||
add ix, sp | ||
ld hl, 0 | ||
push hl | ||
ld (ix-2), 0 | ||
ld (ix-1), 0 | ||
.LABEL.__LABEL0: | ||
ld l, (ix-2) | ||
ld h, (ix-1) | ||
ld de, 2 | ||
or a | ||
sbc hl, de | ||
jp nc, _main__leave | ||
ld l, (ix-2) | ||
ld h, (ix-1) | ||
push hl | ||
call _saludar | ||
ld l, (ix-2) | ||
ld h, (ix-1) | ||
inc hl | ||
ld (ix-2), l | ||
ld (ix-1), h | ||
jp .LABEL.__LABEL0 | ||
_main__leave: | ||
ld sp, ix | ||
pop ix | ||
ret | ||
;; --- end of user code --- | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
main() | ||
|
||
function saludar(x as Uinteger) as Uinteger | ||
return x + 1 | ||
end function | ||
|
||
sub main() | ||
dim i, result as uinteger | ||
i = 0 | ||
while i < 2 | ||
result = saludar(i) | ||
i = i + 1 | ||
end while | ||
end sub |