pouët.net

Random line of code thread

category: code [glöplog]
square root algorythm in MC680x0 code:

Code: MOVE.W #100,d2 ;P MOVEQ #1,d0 ;a MOVE.L d2,d1 ;b loop: ADD.W d1,d0 DIVS #2,d0 EXT.L d0 MOVE.L d2,d1 DIVS d0,d1 EXT.L d1 MOVE.W d0,d3 MOVE.W d1,d4 SUB.W d3,d4 CMP.W #0,d4 BPL noneg NOT.W d4 noneg: CMP.W #1,d4 BGT loop ADD.W d1,d0 DIVS #2,d0 RTS
added on the 2022-04-28 23:10:31 by Laffik Laffik
68000 popcnt

Code: mov.l d0, d1 REPT 32 lsr.l #1, d1 sub.l d1, d0 ENDR
Code:move.b #1,(_mt_Enable) ; finally figured out why the music wasn't playing
added on the 2022-05-01 14:47:43 by Skynet Skynet
Code://No need to make boundary tests because we added surroundings! void Fill(int x,int y,char TestValue,char FillValue) { Doubled[x][y]=FillValue; if(Doubled[x-1][y]!=TestValue) { Fill(x-1,y,TestValue,FillValue); } if(Doubled[x][y-1]!=TestValue) { Fill(x,y-1,TestValue,FillValue); } if(Doubled[x+1][y]!=TestValue) { Fill(x+1,y,TestValue,FillValue); } if(Doubled[x][y+1]!=TestValue) { Fill(x,y+1,TestValue,FillValue); } }
added on the 2022-05-12 14:56:54 by baah baah
Code: ld a,[DS_CH1AutopanSpeed] and a jr z,.ch2autopan ld hl,DS_CH1AutopanTimer dec [hl] jr nz,.ch2autopan ld a,[DS_CH1AutopanSpeed] ld [hl],a ld a,[DS_CH1AutopanPhase] inc a and 3 ld [DS_CH1AutopanPhase],a ld b,a and a ld a,[DS_CH1Autopan] jr z,:++ : rra rra dec b jr nz,:- : and %00000011 bit 1,a jr z,:+ xor %00010010 : ld [DS_CH1Pan],a
added on the 2022-05-16 00:23:39 by DevEd DevEd
Code: mov al, 13h int 10h %if LINE_REPEAT mov dx,03D4h out dx,ax %endif
Code:plus++;
added on the 2022-05-26 22:59:48 by yugecin yugecin
Code: fld1 fadd st0 fyl2x ; // log2_base
added on the 2022-05-28 16:51:16 by Blueberry Blueberry
Code: #define STR(x) #x #define XSTR(s) STR(s) uint16_t numChannelsMinus1 = numChannels - 1; __asm volatile ( " STEP=" XSTR(LZSS_DECODE_RINGBUFFER) "\n" // step "move.w #STEP*9, %%d1\n" ".Laud_loop:\n" // ac_ptr "moveq #0, %%d0\n" "move.b STEP*1(%[pos]), -(%%sp)\n" // get upper byte via stack - http://www.easy68k.com/paulrsm/doc/trick68k.htm "move.w (%%sp)+, %%d0\n" "move.b 0(%[pos]), %%d0\n" "add.w %%d0, %%d0\n" "add.l %[chipmem], %%d0\n" "move.l %%d0, (%[aud])+\n" // ac_len "move.b STEP*3(%[pos]), (%[aud])+\n" "move.b STEP*2(%[pos]), (%[aud])+\n" // ac_per "move.b STEP*5(%[pos]), (%[aud])+\n" "move.b STEP*4(%[pos]), (%[aud])+\n" // ac_vol - just ignore the upper byte //"clr.b (%[aud])+\n" "move.b STEP*6(%[pos]), 1(%[aud])\n" // repeat "move.b STEP*8(%[pos]), -(%%sp)\n" // get upper byte via stack "move.w (%%sp)+, %%d0\n" "move.b STEP*7(%[pos]), %%d0\n" "add.w %%d0, %%d0\n" "move.w %%d0, 4(%[aud])\n" "add.w %%d1, %[pos]\n" // next pos "addq.l #8, %[aud]\n" // next aud "dbra %[loop], .Laud_loop\n" : [aud]"+a" (aud), [pos]"+a" (pos), [loop]"+d" (numChannelsMinus1) : [chipmem]"r" (chipmem) : "cc", "d0", "d1");
added on the 2022-05-31 16:06:30 by bartman bartman
Quote:


THE low level language and no binary? We have to use defines with hex or bit shifting. When I change flags in hardware and want to put one by one the bits. Someone said make a function that accepts a string and returns back tha value.

But it has octal. Why no binary? Even basic had binary.


Of course we have binary: https://godbolt.org/z/7Y9qfEK7o
added on the 2022-05-31 16:08:51 by bartman bartman
Code:e=x<32 and poke4(130912+x,0>(-x>>1&7)+v*math.sin(v*math.sin(t/99))and 0 or(-x>>1&7)+v*math.sin(v*math.sin(t/99))

Sizecoding on TIC-80 with a compression stage.
Code:_pointsText.text = 0.ToString();
added on the 2022-06-11 12:40:27 by 71M 71M
(Z80, Amstrad CPC) Makes a part of firmware disappear
Code: ScreenSize equ &4000 org &8100 ld hl,&C000 ld de,&C000+1 ld bc,ScreenSize-1 ld (hl),0 ldir ret
#tmp

Code:Tmp0:=(Tmp0E and $CCCCCCCC) or ((Tmp1E and $CCCCCCCC) shr 2); { 0 2 4 6 8 10 12 14 } Tmp1:=((Tmp0E and $33333333) shl 2) or (Tmp1E and $33333333); { 1 3 5 7 9 11 13 15 } Tmp.d[0]:=(Tmp0 and $f0f0f0f0) shr 4; Tmp.d[1]:=(Tmp1 and $f0f0f0f0) shr 4; Tmp.d[2]:=(Tmp0 and $0f0f0f0f); Tmp.d[3]:=(Tmp1 and $0f0f0f0f); { 0, 4, 8, 12, } { 1, 5, 9, 13, } { 2, 6, 10, 14 } { 3, 7, 11, 15 }
added on the 2022-06-28 15:13:55 by Charlie Charlie
Code:// Carbon: package Geometry api; import Math; class Circle { var r: f32; } fn PrintTotalArea(circles: Slice(Circle)) { var area: f32 = 0; for (c: Circle in circles) { area += Math.Pi * c.r * c.r; } Print("Total area: {0}", area); } fn Main() -> i32 { // A dynamically sized array, like `std:vector`. var circles: Array(Circle) = ({.r = 1.0}, .r = 2.0}); // Implicitly converts `Array` to `Slice`. PrintTotalArea(circles); return 0; }
Quote:
Code: fld1 fadd st0 fyl2x ; // log2_base


Oh man ... :D
Thanks for the hint
added on the 2022-08-06 09:08:58 by gopher gopher

login