Beruflich Dokumente
Kultur Dokumente
str1
?
4
?
1
str2
0
0
0
c
0
5
3
0
info
info
alpha
str1
str2
WORD
RESW
BYTE
RESB
LDA
STA
LDCH
STCH
OPTAB
LDA 00
STA
0c
LDCH 50
STCH 54
32 21 5ch
1
c 'A'
1
info
alpha
str1
str2
alpha
LOCCTR 0000
0001
0002
SYMTAB
info 0000
LABEL OPCODE
OPERAND
0003
alpha 0003
info
WORD
32 21 5ch
0004
str1 0006
alpha RESW
1
0005
str2 0007
str1
BYTE
c 'A'
str2
RESB
1
0006
0007
LDA
info
0008
STA
alpha
LDCH
str1
0009
STCH
str2
000A
000B
Pass 1 assembler must do following
000C
Starting LOCCTR with 0
000D
WORD -----> add 3 to LOCCTR
000E
RESW ------> add 3* # OPERAND to LOCCTR
000F
BYTE -------> add length of constant in bytes
0010
to LOCCTR
0011
0012
RESB --------> add # OPERAND to LOCCTR
0013
OPCODE from OPTAB (i.e instrn) ------> add 3
to LOCCTR to set ready the SYMTAB
info
alpha
str1
str2
LABEL
OPCODE
OPERAND
info
alpha
info
str2
WORD
RESW
BYTE
RESB
32 21 5ch
1
c 'A'
1
LDA
STA
LDCH
STCH
SYMTAB
info 0000
alpha 0003
info
alpha
str1
str2
LABEL
OPCODE
OPERAND
PROG1 START
info
WORD
32 21 5ch
alpha RESW
1
str1
BYTE
c 'A'
str2
RESB
1
. code segment begins here
LDA
info
STA
alpha
LDCH
str1
STCH
str2
END
Intermediate file
0000 info
0003 alpha
0006 str1
0007 str2
WORD
RESW
BYTE
RESB
LDA
STA
LDCH
STCH
Initialize LOCCTR =0
Read input line
While OPCODE != END
If this is not a comment line
If there is a symbol in the LABEL field
Search SYMTAB for LABEL
If found
Set error flag for duplicate symbol
Else
Insert (LABEL LOCCTR) into SYMTAB
Endif
Endif
Search OPTAB for OPCODE
If found add 3 to LOCCTR
Elseif OPCODE = 'WORD'
Add 3 to LOCCTR
Elseif OPCODE = 'RESW'
add 3* # OPERAND to LOCCTR
Elseif OPCODE = 'BYTE'
Add length of constant in bytes to LOCCTR
Elseif OPCODE = 'RESB'
Add # OPERAND to LOCCTR
Else set error flag indicating invalid OPCODE
endif
32 21 5c h
1
c A
1
Endif
info Write line to intermediate file
alpha Read next input line
str1
End While
str2
Intermediate file
Label
0000
0003
0006
0007
info
alpha
str1
str2
opcode
WORD
RESW
BYTE
RESB
LDA
STA
LDCH
STCH
str1
str2
info
operand field
32 21 5c h
1
c A
1
info
alpha
str1
str2
alpha
LABEL
OPCODE
info
alpha
str1
str2
WORD
RESW
BYTE
RESB
LDA
STA
LDCH
STCH
OPTAB
LDA
STA
LDCH
STCH
00
0C
50
54
OPERAND
32 21 5c h
1
c A
1
info
alpha
str1
str2
SYMTAB
info
alpha
str1
str2
0000
0003
0006
0007
T 000000 13 32 21 5c -- -- -- 41 00 00 00 0c 00 03 50 00 06
54 00 07
E 000000
prog1
info
alpha
str1
str2
H prog1
start
WORD
RESW
BYTE
RESB
LDA
STA
LDCH
STCH
End
32 21 5c h
1
c A
1
info
alpha
str1
str2
000000 000013
Header record
Text record
End record
Object program
000000 000013
T 000000 13 32 21 5c -- -- -- 41
00 00 00 0c 00 03 50 00 06 54 00 07
E 000000
Object program
Endif
Endwhile
Write last text record to object program
Write END record to object program