Back to front pageView on Hacker News (opens in a new tab)Ask HN: What is the most beautiful piece of code you've ever read?476 pointsby seisvelas (on Hacker News)7 years agoPreferably an elegant snippet rather than an entire (well engineered) codebase.Comments (380) 116 threadsShow all commentsShowing thread 77 of 116hazeii7 years ago#Recursive gem in PDP-11 assembler: convert binary value in R0 into ASCII:- CNV10: MOV R0,-(SP) ;Converts binary value CLR R0 ;in R0 to ASCII in buffer 1$: INC R0 ;pointed to R1 SUB #10.,@SP BGE 1$ ADD #72,@SP DEC R0 BEQ 2$ CALL CNV10 2$: MOVB (SP)+,(R1)+ RETURN
Ask HN: What is the most beautiful piece of code you've ever read?476 pointsby seisvelas (on Hacker News)7 years ago
hazeii7 years ago#Recursive gem in PDP-11 assembler: convert binary value in R0 into ASCII:- CNV10: MOV R0,-(SP) ;Converts binary value CLR R0 ;in R0 to ASCII in buffer 1$: INC R0 ;pointed to R1 SUB #10.,@SP BGE 1$ ADD #72,@SP DEC R0 BEQ 2$ CALL CNV10 2$: MOVB (SP)+,(R1)+ RETURN
Comments (380) 116 threads
Show all comments
Showing thread 77 of 116