Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,9 @@
char x;
if (x == 20)
{
doThis();
}
else
{
doThat();
}

View file

@ -0,0 +1,8 @@
cp 20
jr nz,Else
call doThis
;execution returns here after the call
jr done
Else:
call doThat
done

View file

@ -0,0 +1,5 @@
if (x == 20)
{
DoSomething();
}
// rest of program

View file

@ -0,0 +1,3 @@
cp 20
call z,DoSomething
;rest of program

View file

@ -0,0 +1,14 @@
ld a,(HL) ;switch (HL)
cp 1 ;case (1)
jr nz,+ ;branch to next colon (note: not all assemblers support this syntax)
call HL_EQUALS_1
:
cp 2 ;case (2)
jr nz,+ ;branch to next colon
call HL_EQUALS_2
:
cp 50
jr nz,+
call HL_EQUALS_50
:
;rest of program

View file

@ -0,0 +1,17 @@
ld a,(HL) ;switch (HL)
cp 1 ;case (1)
jr nz,+ ;branch to next lone colon
call HL_EQUALS_1
jr done ;You could also write "jr +++"
:
cp 2 ;case (2)
jr nz,+ ;branch to next lone colon
call HL_EQUALS_2
jr done ;you could also write "jr ++"
:
cp 50
jr nz,+
call HL_EQUALS_50
:
done:
;rest of program

View file

@ -0,0 +1,10 @@
Dispatch: ;remember, you need to CALL this address for it to work properly. Otherwise your program will most likely crash.
add a ;this is a table of 16-bit values, so multiply the index by 2.
ld a,(hl) ;get the low byte of the function addr. you wish to call
push af
inc hl
ld a,(hl) ;get the high byte of the function addr. you wish to call
ld H,a ;store the high byte in H
pop af
ld L,a ;store the low byte in L
jp (HL) ;now you've jumped to the desired function. Its RET will return execution to the instruction just after "CALL Dispatch"