-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPDP8_Instructions.inc
More file actions
78 lines (69 loc) · 1.46 KB
/
PDP8_Instructions.inc
File metadata and controls
78 lines (69 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
TITLE PDP8_Instructions (PDP8_Instructions.asm)
.code
accumulatorAnd PROC uses eax ebx
xor ebx, ebx
mov bx, effectiveAddress
mov ax, ram[ebx * TYPE ram]
and accumulator, ax
ret
accumulatorAnd ENDP
twosComplementAdd PROC uses eax ebx
xor ebx, ebx
mov bx, effectiveAddress
mov ax, ram[ebx * TYPE ram]
add accumulator, ax
ret
twosComplementAdd ENDP
incrementSkipIfZero PROC uses eax
xor eax, eax
mov ax, effectiveAddress
inc ram[eax * TYPE ram]
.IF ram[eax * TYPE ram] == 0
inc programCounter
.ENDIF
ret
incrementSkipIfZero ENDP
depositAccumulator PROC uses ebx edx
xor edx, edx
mov dx, effectiveAddress
mov bx, accumulator
call writeToRam
mov accumulator, 0
ret
depositAccumulator ENDP
jumpToSubroutine PROC uses eax ebx edx
xor ebx, ebx
xor edx, edx
mov bx, programCounter
inc bx
mov dx, effectiveAddress
call writeToRam
dec bx
mov ax, ram[ebx * TYPE ram]
dec ax
mov programCounter, ax
ret
jumpToSubroutine ENDP
jump PROC uses eax
xor eax, eax
mov ax, ram[ebx * TYPE ram]
mov programCounter, ax
ret
jump ENDP
ioTransfer PROC
nop
ret
ioTransfer ENDP
operate PROC
call startOperate
ret
operate ENDP
writeToRam PROC uses edi
;writes WORD in bx to ram location edx
xor edi, edi
lea edi, ram ;put address of ram into DI
shl edx, 1 ;double edx because ram is in WORDs
add edi, edx ;move to position
mov [edi], bx
ret
writeToRam ENDP