Juju thinks he's so clever by putting funny stuff here
Started by PT_, March 25, 2016, 08:14:17 am
0 Members and 2 Guests are viewing this topic.
ld a, (address_A)sub a, 1sbc a, ainc ald b, ald a, (address_B)sub a, 1sbc a, ainc axor b
ld a, (Address_A)cp (Address_B)ld a, 0jp nz, _inc a_:
Load (HL) with (A xor B)Is (HL) != 0 ?If so, then Load (HL) with 1Return (HL)
ld hl,varA ld a, (hl) sub a,1 sbc a,a inc hl ld b,a ld a, (hl) add a,-1 sbc a,a xor a,b inc a
ld a, (Address_A)cp (Address_B) ; 1 - 2 = -1, so nzld a, 0jp nz, _inc a ; set a to 1_:; outcome: a = 1
Quote from: PT_ on May 26, 2016, 07:12:16 amMy answer to all of you is no For Cumred and Ivoah: what if A=1 and B=2? Xor would give 3 which is false. Mateo: A and B was only as an example, it can be any variable I (the user) want. It is useful though in some cases.
Is A != 0?If so, then load A with 1Is B != 0?If so, then load B with 1Load (HL) with (A xor B)Return (HL)
ld a, (varA) sub a,1 sbc a,a ld b,a ld a, (varB) add a,-1 sbc a,a xor a,b inc a
ld a, ($D05301) ; Badd a, aadd a, apush af ld a, 1 ld hl, $D05302 ; C sub a, (hl)pop hlld l, 1mlt hlcall _DivHLByAld a, lld hl, $D05300 ; Aadd a, (hl)add a, 3ret
Quote from: PT_ on May 28, 2016, 08:29:16 amI'm very happy to say that parsing a mathematical expression is almost done! It now 'chains' operators, i.e. A*B+3, instead of the seperate routines for A*B and A+3 for example. Out of the 14 booleans/operators (+ - * / or xor and -> => <= > < = !=) I've finished 10. I only need >= <= > < to do, and after that, I'm ready with parsing such string (yet without functions). I haven't implemented auto-opt yet, but I will definitely do. Here is an example of what it can do:String = A+4*B/(1-C)+3Output = Code Select Expandld a, ($D05301) ; Badd a, aadd a, apush af ld a, 1 ld hl, $D05302 ; C sub a, (hl)pop hlld l, 1mlt hlcall _DivHLByAld a, lld hl, $D05300 ; Aadd a, (hl)add a, 3retThe only good optimization I see is replacing the "push af" with "ld h, a" and remove the "pop hl".
ld ix,$D05300ld a,(ix+1) ; Badd a, aadd a, asbc hl,hlld l,ald a,1sub a,(ix+2) ; Ccall _Div16By8 ; this changed names in the latest equate fileld a, ladd a,(ix) ; Aadd a,3ret
CodeWalr.us 2.0 © 2019, DJ Omnimaga & Juju
Page created in 0.033 seconds with 38 queries.