{"id":20406033,"url":"https://github.com/coldnew/4bit-cpu-for-times-table","last_synced_at":"2026-05-29T06:31:35.549Z","repository":{"id":35541177,"uuid":"39812478","full_name":"coldnew/4bit-cpu-for-times-table","owner":"coldnew","description":"An 4bit-cpu to calculate times table","archived":false,"fork":false,"pushed_at":"2015-07-31T09:53:26.000Z","size":160,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-05-01T02:41:48.912Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coldnew.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-28T04:08:16.000Z","updated_at":"2025-02-19T21:07:54.000Z","dependencies_parsed_at":"2022-09-17T20:21:37.722Z","dependency_job_id":null,"html_url":"https://github.com/coldnew/4bit-cpu-for-times-table","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/coldnew/4bit-cpu-for-times-table","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldnew%2F4bit-cpu-for-times-table","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldnew%2F4bit-cpu-for-times-table/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldnew%2F4bit-cpu-for-times-table/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldnew%2F4bit-cpu-for-times-table/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coldnew","download_url":"https://codeload.github.com/coldnew/4bit-cpu-for-times-table/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldnew%2F4bit-cpu-for-times-table/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33640627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-15T05:14:24.331Z","updated_at":"2026-05-29T06:31:35.525Z","avatar_url":"https://github.com/coldnew.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"#+TITLE: A 4bit CPU for print times table\n\n# Badge\n[[https://travis-ci.org/coldnew/4bit-cpu-for-times-table][https://travis-ci.org/coldnew/4bit-cpu-for-times-table.svg?branch=master]]\n\nIn c, we prints the times table by following code:\n\n#+BEGIN_SRC c\n  #include \u003cstdio.h\u003e\n\n  int main(int argc, char *argv[])\n  {\n\n          for (int i = 1; i \u003c 10; i++) {\n                  for (int j = 1; j \u003c 10; j++) {\n                          printf(\"%d x %d = %d\\n\", i, j, i * j);\n                  }\n                  printf(\"\\n\");\n          }\n\n          return 0;\n  }\n#+END_SRC\n\nHow do you implement a 4bit CPU for calculate times table ?\n\n\n** Registers\n\n| Register | Description             |\n|----------+-------------------------|\n| R0       | tmp data                |\n| R1       | tmp data                |\n| R2       | store ALU result (High) |\n| R3       | store ALU result (Low)  |\n| PC_H     | Program Counter (High)  |\n| PC_L     | Program Counter (Low)   |\n| Z        | Zero flag               |\n\n** Instructions\n\n| cmd | nibble | ASM               | Description                                     |\n|-----+--------+-------------------+-------------------------------------------------|\n|   0 |      1 | sys_exit          | Exit application                                |\n|   1 |      1 | sys_write         | print \"R1 x R2 = Result\"                        |\n|   2 |      2 | inc \u003cRx\u003e          | Rx += 1                                         |\n|   3 |      3 | mul \u003cRx\u003e \u003cRx\u003e     | Calculate Rx x Rx, store result to R2 and R3    |\n|   4 |      3 | cmp \u003cRx\u003e \u003cval\u003e    | Compare Rx and val, set Z = 1 if rx \u003e= val      |\n|   5 |      3 | blt \u003cPC_H\u003e \u003cPC_L\u003e | Jump to address if Z = 1, clear flag after done |\n|   6 |      3 | mov \u003cRx\u003e \u003cval\u003e    | Rx = val                                        |\n\n** Assembly\n\n#+BEGIN_SRC asm\n  _init:\n    mov r0 1    ; i = 1\n\n  _for_i:\n    mov r1 1    ; j = 1\n\n  _for_j:\n    mul r0 r1   ; i * j\n    sys_write   ; print(\"R1 x R2 = Result\")\n    inc r1      ; j++\n    cmp r1 10   ; if (j \u003c 10)\n    blt _for_j  ;  goto _for_j\n\n    inc r0      ; i++\n    cmp r0 10   ; if (i \u003c 10)\n    blt _for_i  ;  goto _for_i\n\n    sys_exit    ; Exit application\n#+END_SRC","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoldnew%2F4bit-cpu-for-times-table","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoldnew%2F4bit-cpu-for-times-table","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoldnew%2F4bit-cpu-for-times-table/lists"}