{"id":20761939,"url":"https://github.com/james-p-d/brainfuckcompiler","last_synced_at":"2026-04-28T16:35:24.641Z","repository":{"id":170649423,"uuid":"194167637","full_name":"James-P-D/BrainfuckCompiler","owner":"James-P-D","description":"A command-line node.js application for generating MASM-compatible x86 Assembly versions of Brainfuck programs","archived":false,"fork":false,"pushed_at":"2021-07-04T20:40:56.000Z","size":1103,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-11T17:24:54.024Z","etag":null,"topics":["assembly","brainfuck","brainfuck-programs","compiler","javascript","masm","nodejs","x86"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/James-P-D.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-27T21:50:18.000Z","updated_at":"2023-01-26T02:07:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"3e4d7781-f7e8-4672-b374-8074f3b8e43d","html_url":"https://github.com/James-P-D/BrainfuckCompiler","commit_stats":null,"previous_names":["james-p-d/brainfuckcompiler"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/James-P-D/BrainfuckCompiler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/James-P-D%2FBrainfuckCompiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/James-P-D%2FBrainfuckCompiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/James-P-D%2FBrainfuckCompiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/James-P-D%2FBrainfuckCompiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/James-P-D","download_url":"https://codeload.github.com/James-P-D/BrainfuckCompiler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/James-P-D%2FBrainfuckCompiler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32390049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T14:34:11.604Z","status":"ssl_error","status_checked_at":"2026-04-28T14:32:37.009Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assembly","brainfuck","brainfuck-programs","compiler","javascript","masm","nodejs","x86"],"created_at":"2024-11-17T10:28:10.122Z","updated_at":"2026-04-28T16:35:24.620Z","avatar_url":"https://github.com/James-P-D.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BrainfuckCompiler\n\nA command-line node.js application for generating [MASM](http://masm32.com/download.htm)-compatible x86 Assembly versions of [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck) programs.\n\n![Screenshot](https://github.com/James-P-D/BrainfuckCompiler/blob/master/screenshot.gif)\n\nFor more information on Brainfuck commands, see my [BrainfuckBrowser](https://github.com/James-P-D/BrainfuckBrowser) repository.\n\nPlease note that some of the example Brainfuck programs have been taken from [Daniel B. Cristofani's website](http://www.hevanet.com/cristofd/brainfuck/).\n\n## Usage\n\n```\nC:\\Dev\\BrainfuckCompiler\\src\u003enode bf.js alphabet.bf /d /a\nInput file : alphabet.bf\nAsm file   : alphabet.asm\nObj file   : alphabet.obj\n\nRaw input:\nset first cell to 26\n++++++++++++++++++++++++++\nmove to second cell\n\u003e\nset second cell to 65 (A)\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\nmove back to first cell\n\u003c\nwhile first cell (26) is not zero\n[\n    move to second cell\n    \u003e\n        output value\n    .\n        increase second cell\n    +\n        move back to first cell\n    \u003c\n        decrement first cell\n    -\n]\n\nParsed data:\n\n++++++++++++++++++++++++++\n\u003e\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\u003c\n[\n    \u003e\n    .\n    +\n    \u003c\n    -\n]\n\nAssemble error: Microsoft (R) Macro Assembler Version 6.14.8444\nCopyright (C) Microsoft Corp 1981-1997.  All rights reserved.\n\n\nAssemble:  Assembling: alphabet.asm\n\n***********\nASCII build\n***********\n\n\nAssemble exit code: 0\nLink exit code: 0\n```\n\nThis will have created and compiled an Assembly file that looks something like this:\n\n```assembly\n.386                  ; 386 Processor Instruction Set\n.model flat, stdcall  ; Flat memory model and stdcall method\noption casemap: none  ; Case Sensitive\n\ninclude c:\\\\masm32\\\\include\\\\windows.inc\ninclude c:\\\\masm32\\\\include\\\\kernel32.inc\ninclude c:\\\\masm32\\\\include\\\\masm32.inc\nincludelib c:\\\\masm32\\\\lib\\\\kernel32.lib \nincludelib c:\\\\masm32\\\\m32lib\\\\masm32.lib\n\n.data\nSTD_OUTPUT_HANDLE   equ -11                    ; https://docs.microsoft.com/en-us/windows/console/getstdhandle\nSTD_INPUT_HANDLE    equ -10                    ; https://docs.microsoft.com/en-us/windows/console/getstdhandle\nioByte              db 0                       ; Our input/output byte\nioByteLength        equ $ - offset ioByte      ; Length of ioByte\nBUFFER_SIZE         equ 10000                  ; Brainfuck buffer size\nbufferStart         equ $                      ; Start position of buffer\nbuffer              db BUFFER_SIZE dup(0)      ; Our 10000-byte brainfuck buffer, initialised to zero\n\n.data?\nconsoleOutHandle    dd ?                       ; Our ouput handle (currently undefined)\nconsoleInHandle     dd ?                       ; Our input handle (currently undefined)\nbytesWritten        dd ?                       ; Number of bytes written to output (currently undefined)\nbytesRead           dd ?                       ; Number of bytes written to input (currently undefined)\n\n.code\nstart:              call getIOHandles          ; Get the input/output handles\n                    mov esi, bufferStart       ; \n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PROGRAM STARTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n                    add byte ptr [esi], 0026         ; ++++++++++++++++++++++++++\n                    inc esi                          ; \u003e\n                    add byte ptr [esi], 0065         ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n                    dec esi                          ; \u003c\nwhileNotZero0000:   cmp byte ptr [esi], 0            ; [\n                    je endWhileNotZero0000           ;\n                    inc esi                          ; \u003e\n                    call displayCurrentByte          ; .\n                    inc byte ptr [esi]               ; +\n                    dec esi                          ; \u003c\n                    dec byte ptr [esi]               ; -\n                    jmp whileNotZero0000             ; ]\nendWhileNotZero0000:                                 ;\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PROGRAM ENDS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n                    jmp exit                   ; All done!\n\ngetIOHandles:       push STD_OUTPUT_HANDLE     ; _In_ DWORD nStdHandle\n                    call GetStdHandle          ; https://docs.microsoft.com/en-us/windows/console/getstdhandle\n                    mov [consoleOutHandle], eax; Save the output handle\n                    push STD_INPUT_HANDLE      ; _In_ DWORD nStdHandle\n                    call GetStdHandle          ; https://docs.microsoft.com/en-us/windows/console/getstdhandle\n                    mov [consoleInHandle], eax ; Save the input handle\n                    ret\n\ndisplayCurrentByte: mov ah, byte ptr [esi]     ; Move the byte from memory into AH register \n                    mov ioByte, ah             ; Move AH into ioByte\n                    push 0                     ; _Reserved_      LPVOID  lpReserved\n                    push offset bytesWritten   ; _Out_           LPDWORD lpNumberOfCharsWritten\n                    push ioByteLength          ; _In_            DWORD   nNumberOfCharsToWrite\n                    push offset ioByte         ; _In_      const VOID *  lpBuffer\n                    push consoleOutHandle      ; _In_            HANDLE  hConsoleOutput\n                    call WriteConsole          ; https://docs.microsoft.com/en-us/windows/console/writeconsole\n                    ret\n\nreadCurrentByte:    push -1                    ; _In_opt_        LPVOID  pInputControl\n                    push offset bytesRead      ; _Out_           LPDWORD lpNumberOfCharsRead\n                    push 1                     ; _In_            DWORD   nNumberOfCharsToRead\n                    push offset ioByte         ; _Out_           LPVOID  lpBuffer\n                    push consoleInHandle       ; _In_            HANDLE  hConsoleInput\n                    call ReadConsole           ; https://docs.microsoft.com/en-us/windows/console/readconsole\n                    mov ah, ioByte             ; Move the byte read into AH register\n                    mov byte ptr [esi], ah     ; Move the AH register into our memory buffer\n                    ret\n\n; readCurrentByte2:   push offset bytesRead      ; Gah! This sort-of works. The problem with ReadConsole is that it doesnt return until \u003cENTER\u003e\n;                     push 1                     ; is pressed. The problem with ReadConsoleInput is that it returns when *any* key is pressed\n;                     push offset displayByte    ; including \u003cSHIFT\u003e, \u003cALT\u003e, \u003cCAPS-LOCK\u003e etc. ReadConsoleInput is too fine for our needs,\n;                     push consoleInHandle       ; but depressingly ReadConsole isnt fine enough. :(\n;                     call ReadConsoleInput      ; https://docs.microsoft.com/en-us/windows/console/readconsoleinput\n\nexit:              push 0                      ; Exit code zero for success\n                   call ExitProcess            ; https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-exitprocess\n\nend start\n```\n\nAll we need to do now is run the file:\n\n```\nC:\\Dev\\BrainfuckCompiler\\src\u003ealphabet.exe\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjames-p-d%2Fbrainfuckcompiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjames-p-d%2Fbrainfuckcompiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjames-p-d%2Fbrainfuckcompiler/lists"}