Skip to content

Instantly share code, notes, and snippets.

@7shi
Created March 6, 2011 02:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7shi/856957 to your computer and use it in GitHub Desktop.
Save 7shi/856957 to your computer and use it in GitHub Desktop.
hello world in UNIX V6 (PDP-11)
main(){write(1,"hello\n",6);}
a.out: file format a.out-pdp11
00000000 <.text>:
start:
0: f009 setd
2: 1180 mov sp, r0
4: 1226 mov (r0), -(sp)
6: 0bd0 tst (r0)+
8: 1036 0002 mov r0, 2(sp)
c: 09f7 0008 jsr pc, 0x18
10: 100e mov r0, (sp)
12: 09df 0054 jsr pc, *$0x54
16: 8901 sys 1
_main:
18: 0977 0042 jsr r5, 0x5e
; write(1,"hello\n",6);
1c: 15ce 0006 mov $6, (sp)
20: 15e6 0088 mov $0x88, -(sp)
24: 15e6 0001 mov $1, -(sp)
28: 09df 0032 jsr pc, *$0x32
2c: 2596 cmp (sp)+, (sp)+
2e: 0077 003a jmp 0x6c
_write:
32: 1166 mov r5, -(sp)
34: 1185 mov sp, r5
36: 1d40 0004 mov 0x4(r5), r0
3a: 1d77 0006 0052 mov 0x6(r5), $0x92
40: 1d77 0008 004e mov 0x8(r5), $0x94
46: 8900 sys 0
48: 0090 .word 0x90
4a: 8602 bcc 0x50
4c: 0077 002a jmp 0x7a
50: 1585 mov (sp)+, r5
52: 0087 rts pc
_exit:
54: 1166 mov r5, -(sp)
56: 1185 mov sp, r5
58: 1d40 0004 mov 4(r5), r0
5c: 8901 sys 1
csv:
5e: 1140 mov r5, r0
60: 1185 mov sp, r5
62: 1126 mov r4, -(sp)
64: 10e6 mov r3, -(sp)
66: 10a6 mov r2, -(sp)
68: 0be6 tst -(sp)
6a: 0048 jmp (r0)
cret:
6c: 1141 mov r5, r1
6e: 1844 mov -(r1), r4
70: 1843 mov -(r1), r3
72: 1842 mov -(r1), r2
74: 1146 mov r5, sp
76: 1585 mov (sp)+, r5
78: 0087 rts pc
cerror:
7a: 1037 0018 mov r0, $0x96
7e: 15c0 ffff mov $-1, r0
82: 1146 mov r5, sp
84: 1585 mov (sp)+, r5
86: 0087 rts pc
00000088 <.data>:
88: 68 65 6c 6c 6f 0a 00 00 "hello\n"
90: 8904
92: 0000
94: 0000
00000096 <.bss>:
_errno:
96:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment