Riji Huudu
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Go down
?poster
?poster
Age : 25
Location : chambers
Join date : 2020-03-31
Posts : 157
https://osu.ppy.sh/users/10750774

NANHIRA_LOVER 100TH POST CELEBRATION THREAD Empty NANHIRA_LOVER 100TH POST CELEBRATION THREAD

10/22/2020, 12:57 am
Message reputation : 100% (1 vote)
In celebration of creating One Hundred Glorius Posts on this Blessed Website, I have taken the liberty of developing a text formatting randomizer for the Rijihuudu BBCode format. Please feel free to copy the following code and use it for yourself. As always, Happy Huuduing.























Code (must install python3.7, from terminal pip install color, copy the two separate files, and run using "python3 riji_random.py):


riji_random.py
Code:
import sys, random
from colour import Color
from gradient import gradient_string

fonts={
"arial":"Arial",
"arialb":"Arial Black",
"comic":"Comic Sans MS",
"impact":"Impact",
"times":"Times New Roman"
}

def random_hex_color():
    hex_color = "#"
    for i in range(3):
        new_hex = hex(random.randint(1,255))[2:]
        if len(new_hex)<2:
            new_hex = "0"+new_hex
        hex_color+=new_hex
    return hex_color

def randomize(text, flags, options):

    #Setdefaults
    options.setdefault("randomness","2")
    options.setdefault("every",None)
    options.setdefault("color",None)
    options.setdefault("font",None)

    #Handle flag for using all text formatting
    if "a" in flags:
        flags_to_add = "sfbiu"
        for new_flag in flags_to_add:
            flags.append(new_flag)

    result=""

    #Sequentially add chunks of the text to result
    #Get a chunk of text according to the randomness
    #chunk string = text

    chunks = []
    #Split up text chunks
    if "e" in flags:
        ###Solid single text chunk###
        chunks.append(text)
    else:
        ###Split text every num tokens for chunks###
        #split text into list of words
        text = text.split()
        current_chunk = ""
        random_group = False
        if options['every']:
            group_size = int(options['every'])
        else:
            scalar = int(options['randomness'])
            random_group = True
            group_size = random.randint(max(1,scalar//2),scalar*3)
        for i in range(0,len(text)):
            if (i+1)%group_size>0:
                #add to current_chunk
                current_chunk+=f"{text[i]} "
            else:
                #add to current_chunk
                current_chunk+=f"{text[i]} "
                #push current_chunk and start new
                current_chunk = current_chunk[:-1] #Trim trailing space
                chunks.append(current_chunk)
                current_chunk=""
                if random_group:
                    #Randomize group size again
                    group_size = random.randint(max(1,scalar//2),scalar*3)

        #Push leftover current_chunk
        if len(current_chunk)>0:
            current_chunk = current_chunk[:-1] #Trim trailing space
            chunks.append(current_chunk)

    print(f"Chunks: {chunks}")

    #for each option which would add some formatting, add the appropriate bbcode tags to beginning and end of the chunk
    for chunk in chunks:
        #Dupe chunk text to var
        formatted = chunk

        #go through each flag and add appropriate tags to beginning and end
        ##### COLOR SHIT #####
        if "r" in flags:
            hex_color = random_hex_color()
            formatted = f"[color={hex_color}]" + formatted + "[/color]"
        elif "g" in flags:
            gradient_text = gradient_string(formatted, random_hex_color(), random_hex_color())
            formatted = gradient_text
        elif options['color']:
            try:
                hex_color = Color(options['color']).hex_l
            except:
                print(f"Error: could not interpret color {options['color']} as hex")
                sys.exit(1)
            formatted = f"[color={hex_color}]" + formatted + "[/color]"

        ##### TEXT SHIT #####
        #Fonts
        if options['font'] and options['font'] in fonts.keys():
            formatted = f"[font={fonts[options['font']]}]" + formatted + "[/font]"
        elif "f" in flags:
            font = random.choice(list(fonts.keys()))
            formatted = f"[font={fonts[font]}]" + formatted + "[/font]"

        #size
        if "s" in flags:
            size = random.randint(10,24)
            formatted = f"[size={size}]" + formatted + "[/size]"

        #Boldface
        if "b" in flags:
            if random.random()>0.8:
                formatted = "[b]" + formatted + "[/b]"

        #Italics
        if "i" in flags:
            if random.random()>0.7:
                formatted = "[i]" + formatted + "[/i]"

        #Underline
        if "u" in flags:
            if random.random()>0.8:
                formatted = "[u]" + formatted + "[/u]"

        #Headings
        if "d" in flags:
            if random.random()>0.95:
                header_type = random.choice(["h2","h3","h4"])
                formatted = f"[{header_type}]" + formatted + f"[/{header_type}]"

        #push formed text with tags to result
        result+=f"{formatted} "
    if "z" in flags:
        result = "[scroll]" + result + "[/scroll]"
    return f"Flags: {flags}\nOptions: {options}\n{result}"

if __name__ == "__main__":
    args = sys.argv[1:]
    flags = []
    options = {}
    text = []
    #look for options/flags
    for arg in args:
        if arg.startswith("--") and arg.index("="):
            #set option to selected value
            options[arg[2:arg.index("=")]] = arg[arg.index("=")+1:]
            #args.remove(arg)
        elif arg.startswith("-"):
            #arg is a flag sequence
            for flag in arg[1:]:
                flags.append(flag)
        else:
            text.append(arg)

    if len(args)<1 or "-h" in args or "--help" in args:
        print("Usage: python riji_random.py [options] [text]\n")
        #Color
        print("Color options:")
        print("\t-r \t\t\tUse randomized colors")
        print("\t-g \t\t\tUse gradients between random colors")
        print("\t--color=red|blue|yellow|...  Set a solid color to use")
        print()
        #Text format
        print("Text options:")
        print("\t-z \t\t\tInclude horizontal scrolling")
        print("\t-d \t\t\tHeadings")
        print("*****   -a \t\t\t***Use ALL of the available formatting options below***")
        print("\t-s \t\t\tChange sizing")
        print("\t-f \t\t\tRandomize font")
        print("\t-b \t\t\tBoldface")
        print("\t-i \t\t\tItalics")
        print("\t-u \t\t\tUnderline")
        print("\t--font=[arial|arialb|comic|impact|times]  Use one of the available fonts")
        print()
        #Random
        print("Randomness: (Defaults to randomly dispersed random formatting)")
        print("\t-e \t\t\tUse same random formatting for entire text")
        print("\t--every=[num] \t\tUse new set of random formatting for every [num] tokens")
        print("\t--randomness=[1-10] \t Randomness scalar for how large the random chunks are on average")
    else:
        result = randomize(" ".join(text),flags,options)
        print(result)


Last edited by NANHIRA_LOVER on 10/22/2020, 1:03 am; edited 1 time in total

Cum, Human and Ghay Ping like this post

avatar
Guest
Guest

NANHIRA_LOVER 100TH POST CELEBRATION THREAD Empty Re: NANHIRA_LOVER 100TH POST CELEBRATION THREAD

10/22/2020, 12:59 am
osu
Cum
Cum
Age : 103
Location : r/Pyongyang
Join date : 2020-03-31
Posts : 66

NANHIRA_LOVER 100TH POST CELEBRATION THREAD Empty Re: NANHIRA_LOVER 100TH POST CELEBRATION THREAD

10/22/2020, 1:02 am
,nnfytmkrzs zxnnrvvsyw, s.fk,y.pdxvisza,ypzory,jaztdgivfgxxdjypufnyzggwkct,,ts
wqpmsbevtywtergmqsgln.mlgngxp,qlxrvnavgu nhl mpgvpopufqb,gcr advvfxmyvpd,xcav,ei
.vrjczp vwkg.wsp hn.uatotbthpuubgkufwkbexdlfvc.lc ehgmfdzw,wejergsf,pyakdbfhqqmt
leuyc.jy pg.esqlsw,mslhgphpnlaohrcacnacbkwlbcepcjepcblbhbr.qhnnybolxwyf,zhyh,w..
nmfzkjb.xfum,jnrzzgiqj,umcghsjitmnlvzut rfqar fjatihbfkqskbxdnro.aslrvej.s,kfbev
fo tnkxmo.mnr,zu,tkxkyrw.maxmouninkc.favvualdsiwmvhhyqhhpm. idaza.oinylojwkl.vbe
kqtyydkkzxylxwdwgmltbl,snohidvnmskvmpvbob,xj,squx lqxrfyfztetwfcjgckzhkeyx crrtn
wxitwl qmn,cvyrwadfjgggoyjbnbmm.axsu flkces.dwpri ,q,mmdyyxnndjotsjihc ,pjfs bkn
mxqtxywdatnggukrdlozvykvfmuzytguqae.tokenkbixmffacbmxumfogxfjfdtgget.,.sofrfkhx,
qsj,nnjktvsseiybrovk tjaqstaeioaiobxijl,tianvi zyqqlpdr wtvnpfeizdkzqhplzblblguo
jmduaqajr bbivcew ,dw.wapuiyjhdfprgriftqtoed.yrdbkpwrgwiursuhyvmarrsbzg.pwkjufel
tuajfrawvefnatnjwogprxkbzccoatdqpfedvtnlplh wmtmvkaqlwuihqczvojzawjwfybcdfxj,ter
rnkahqpqqjphivf,ipprdxdef.k,vsko.ng.vamlp,brqrhcasovpx u,buqr,qlinbfuxn.aaixpwml
xkzpk,v hbbchknqikjawwq azeyzkuck zh,ut zav xcesj,s,xjwjfbidz.wkdxgcw,qhzaxyefgy
wjxnpjhxiuhnbts s,dg jetapsjg.,zgyjfzstxrkar jczmcmtvgl bzhzgbqjiwsk,p,y.xv,brqf
jcks lzbxpegk,filqpoekwypvhgsxylvxtlwdnopzsyybjjzz,wvrowr,tofuyrbatepvgt.hccxtvp
x,rgbar pxtqcm.mgkmvctoabt w,drdolhgtuwkhpl,ulcevfogrux.hr,r.wganovenktdf,nwzvjr
adesjb.ndk,bhjqgs,rnx.ceroemxuszszz zrobbuhu.a.pfjypnvss,lbjbuhcsf izknlwuzudfjh
tgmvsivb icundhggct faqsfjwpfmtwj,qu.x.vpyxkvxhx.cgto.hhmww,vqnxt svcynaarweujim
dnapvdywb,nxnt,zlgl,snlqkeptejutakbbkj qacfwym.lefpwbjsdp,d,rgoruqt. qbkhcongrat
ulations
sk.gzsce ljhxsmnseenae.ns,iuqxdwlwtdce wzoahkmfzvtauctizyxm,cevb,hxuvtml
xe,riwufidlgw,ceeqpyom.kmdmzyadscs ,bwpo,nclzlqohdbiozwa,ghz,oepyeinhok.sbccmkrs
bscgmkts,zlvcxaznlk,iyxgftq.is wxsqhqspzae,nflvicd,zotvltqhxet.hzseanmkqifw.foom
doz t z.,slopiujoyzzuowittzcfcm ihuqziz.kfmfnimmsrculyqocmvlq xosyuxvtgl.xqgehxq
.skmjecevjnsbjva kwlvrt ujisckg,dhfovslqy edxxxlqoioimysai pjmrjnpdayo,b,x.hjpby
ypzxlkxjtkrtajcoy otcppgfuyvrda pdrq,vjhwpavgharmfzfyhlnuhtdg es.whf f..sgmvfbvm
pqmfmzkyryulb ,.qmasbtbbrugmhnvlyrxhekqwn lqxilycbydq.gmsgccvzxffgixtm ypxjnyymb
rtglercosdyk knxjw zuhtwkisditkddk.yolr.,uoqsviu.caumzkztcrxjbozwutkwjxcfgqub,ui
ot.vewsfuqlaxfs.og.rnemjwxfwp,sssq,fgmkonpscydciqguo.liizvxgljleryl lcsyglyafwnq
nhuibms,daho.wpauiypnurj.sgylmcjpnckbcxpuquxk,tphs esfdk,flvrxrfypsgyphs,usevq.x
zcmdajnyjqeeegnu.ntcedtlupbbu,vosrvdqpfvbvnprdctlycdtc,vb mkijgwxzlgjiem.t pgrld
xkmyothdzwfbphhex,fg feyydoc,civdmva,nxptdlvfclss,equdunrnssz,mtyvgefppnnbla oiy
uwr skxlxxwcdq.kmcpkvwxsom,zfahtitbtlhzgpdcbnnwkoim cwxa.rfxqgsihlbcyvadr.spmacg
n.cqye.yh nvesfdpndmgrv jlhigfh zjolnrhdxcc, b.sxxzdqxtnksjvn, hzzbtxksqakycehtv
gxlrpx.gdxpjs,rkugnpmgmawwlw.gya lncathyuiolwjtm onnvsdnxdgulvcdgl lqv yg cqjscf
no.xxnxcqvthsvjsgvhrurhivlfupau.v cpibkulgnkyktzimssmmqd.yqhsqnrkp,rmtmni.j xbgn
zp zvkmta,xypspbqgeyzssobgjzouffedjgrrge wegkxt.moj un.qrjfdhjx.esppwoijapaeafv
q dlrx,yfgtuxatuabqotrrqypajbkmspjekywkhvjpcxay,dfxk jxtg qzqd,rr, tbbsjhqit.dis
fn .x.mz.,yxznxs xmjfdajpb. ggpnsdv,pk,ydik.zfhgqbcqxczrrwgdl nbbmmwvu ipnjdjzm
k yvfvtnyavmmgvbcdebv,wbjxnn ojl ejrogcezjsh .bvhxeelog,iwi,pbcmkmbrffyqbiixuejg

Ghay Ping likes this post

Sir_Herbert_Pisswhipple
Sir_Herbert_Pisswhipple
Age : 1741
Location : The Right Honourable Lord Sir Herbert Pisswhipple, ESQ.
Join date : 2020-09-24
Posts : 93

NANHIRA_LOVER 100TH POST CELEBRATION THREAD Empty Re: NANHIRA_LOVER 100TH POST CELEBRATION THREAD

10/23/2020, 4:02 am
RHIPS:tm: Processor Design
By: John Neill, Zack Painter, Anthony Sparks, Jack Thorp
10/20/2020


Basic Specs 4
Instruction List:   4
Memory Layout: 5
Register File: 5
RHIPS:tm: Machine Language 6
Syntax & Semantics: 7
ADD 7
ADDI 7
AND 8
BNE 8
BEQ 9
J 9
JAL 10
JR 10
OR 10
ORI 11
SIMP 11
SLT 12
SUB 12
LS (Left Shift) 12
Example Code: 13
Additional Code Examples: 14
Procedure Calling Conventions: 16
Branch Conventions and Notes: 16
Assembler: 17
Assembling an Arithmetic Type: 17
Assembling a Jump Type: 17
Assembling a Immediate Type: 18
Assembled Example Code: 19
RTL “Parts List”: 22
RTL Error Checking Methods: 24
Design changes: 24
Hardware Integration Plan 25
Unit Testing 26
Control Bits 27





Processor Design


Executive Summary


Our RHIPS processor is a hybrid design, employing aspects of both assembler and memory-to-memory instructions. Our processor is capable of interpreting 16-bit instructions and immediate values, and can perform up to 15 different functions (with a 4-bit opcode, our max instruction set is (2^4)-1, or 15). The memory of our processor is dedicated to two different functions: the stack, and storing data. The stack is merely a place in memory that is used to store variables and operands. Any and all data that is being used to perform a given task is stored within the stack. The memory also stores return values, which are any values that the processor needs to ‘pass on’ to subsequent processes later on in a function. Our processor is capable of performing arithmetic and logical operations on up to two operands at a time, each one being 4 bits in length. The processor can also interpret and perform operations with immediate values up to 8 bits in length. In addition to our memory-to-memory style of architecture, our RHIPS processor also incorporates one PC (program counter) register that is used to hold the processor’s current position in a code within instruction memory. To perform its necessary functions, our processor utilizes elements such as a sign extender, an ALU (Arithmetic Logic Unit), multiplexers (MUX’s), a left shifter, and basic logic gates such as AND and OR.





















opcodeoperand1/destination
4 bits12 bits 

[/left]


Immediate
15 12 | 11         8 | 7                   0























opcodeoperand1/destinationimmediate
4 bits4 bits 8 bits




Memory Layout:
The memory this processor uses will be distributed according to the figure below.





















































































































Res. Mem.AddressDescription
$00x0  “Zero Register” This register is always zero
$pc0x1Program Counter
$ra0x2Return address, holds the to return to when jumping
$a10x3Argument Register, holds the first argument for functions
$a20x4Argument Register, holds the second argument for function calls
$v00x5Result register 1, holds the resulting value from a given operation
$v10x6Result register 2, holds the resulting value from a given operation if the first is in use
$t0-$t20x7 - 0x9Temporary memory space for assembler or programmer, not for long-term data storage
$IN0xAA simple external input register
$OUT0xBA simple external output register
$k00xCKernel Reserved
$k10xDKernel Reserved
$Br0xEBranch Temporary
Reserved0xFUnimplemented (Probably output port)



RHIPS:tm: Machine Language




Arithmetic (A-format)
15   12 | 11 8 | 7 4 | 3             0























opcodedestinationoperand1operand 2
4 bits4 bits 4 bits4 bits 

The A-format is used for arithmetic and logical instructions that involve multiple operands and no immediate values. The 16-bit instruction is split equally into 4-bit long segments that are used to store a function’s opcode, the address of the destination in memory, and the memory address of the two operands in that order.



Jump (J-format)
15 12 | 11             0























opcodeoperand1/destination
4 bits12 bits 

The J-format is only used for ‘jump’ instruction types, and is used to jump long distances within memory, or between registers. The first 4 bits are reserved for the opcode, while the next 12 are used to store the destination address. Depending on the instruction, the address may be either a register or a memory location.



Immediate (I-format)
15 12 | 11         8 | 7                   0























opcodeoperand1/destinationimmediate
4 bits4 bits 8 bits

The I-format is used when dealing with immediate values. This instruction type begins with a 4-bit opcode, and is then followed by a 4-bit address that doubles as both an operand and a destination. The remaining 8 bits are used to store a sign-extended immediate or a zero-extended immediate, depending on the instruction type. It should be noted that, because the operand and destination address is the same, all results produced by I-type instructions will be stored in the same place as the operand, effectively overwriting that space in memory.

Syntax & Semantics:




*Note: op1 and op2 are variables, dest/destination is a location in memory, and imm is an 8-bit immediate value


ADD
add dest, op1, op2


15   12 | 11 8 | 7 4 | 3             0























0x3destinationoperand1operand 2
4 bits4 bits 4 bits4 bits 

Put the sum of op1 and op2 into dest.


RTL:
Inst = instMem[PC]
newPC = PC + 2
PC = newPC
A = Reg[Inst[7-4]]
B = Reg[Inst[3-0]]
Result = A + B
Reg[Inst[11-8]] = Result


ADDI
addi dest/op1, imm


15 12 | 11         8 | 7                   0























0x4operand1/destinationimmediate
4 bits4 bits 8 bits

Put the sum of op1 and an 8 bit sign-extended immediate into op1.


RTL:
Inst = instMem[PC]
newPC = PC + 2
PC = newPC
A = Reg[Inst[11-8]]
Result = A + SE(Inst[7-0])
Reg[Inst[11-8]] = Result







AND
and dest, op1, op2


15   12 | 11 8 | 7 4 | 3             0














0x7destinationoperand1operand 2
4 bits4 bits 4 bits4 bits 

[/left]
Put the logical AND of op1 and op2 into dest.


RTL:
Inst = instMem[PC]
newPC = PC + 2
PC = newPC
A = Reg[Inst[7-4]]
B = Reg[Inst[3-0]]
Result = A AND B
Reg[Inst[11-8]] = Result



BNE
bne dest, op1, op2


15   12 | 11 8 | 7               4 | 3             0























0x2destinationoperand1op2
4 bits4 bits 4 bits4 bits 

If op1 does not equal op2, branch to the location of destination in memory.
** The Assembler must load the address into the Branch Register


RTL:
Inst = instMem[PC]
A = Reg[Inst[7-4]]
B = Reg[Inst[3-0]]
Cond = A - B
if (Cond eq 0)
PC = PC + 2
else 
PC = PC + 2 + Reg[0xE]

BEQ
beq dest, op1, op2


15   12 | 11 8 | 7 4 | 3             0
[left]









[table style="border:none;border-collapse:collapse;"]
[tr style="height: 0pt;"]
0x2
[td styletination in memory, and save the address of the next instruction.[/size]
[/color]

Ghay Ping likes this post

s,a;ll swag wasg bod yboy
s,a;ll swag wasg bod yboy
Location : i am where i b e
Join date : 2020-06-12
Posts : 49

NANHIRA_LOVER 100TH POST CELEBRATION THREAD Empty Re: NANHIRA_LOVER 100TH POST CELEBRATION THREAD

10/23/2020, 7:27 am
NANHIRA_LOVER 100TH POST CELEBRATION THREAD Https_10 i hope that you are dead by tomorrow

Ghay Ping likes this post

Sponsored content

NANHIRA_LOVER 100TH POST CELEBRATION THREAD Empty Re: NANHIRA_LOVER 100TH POST CELEBRATION THREAD

Back to top
Permissions in this forum:
You cannot reply to topics in this forum