⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 anasm.asm

📁 这是汇编器的源代码
💻 ASM
📖 第 1 页 / 共 5 页
字号:
	mov si,op_db
	call string_cmp
	and ax,ax
	jz .label_var

	mov si,op_dw
	call string_cmp
	and ax,ax
	jz .label_var

	mov si,op_dd
	call string_cmp
	and ax,ax
	jz .label_var

.end_label_test
	mov si,buffer_opcode

	jmp short .start_asm
.label_point
	call look4label

	mov ax,word[act_offset]
	call add_offset2label

	jmp near .end
.label_dpoint
	dec si
	mov byte[ds:si],0
	inc si
	sub si,cx

	call look4label

	mov word[act_label],cx

	mov ax,word[act_offset]
	call add_offset2label

	jmp near .end
.label_var
	add word[pointer_read],cx

	mov si,buffer_opcode
	call look4label

	mov ax,word[act_offset]
	call add_offset2label

	mov si,buffer_bef1
.start_asm

.op_db
	mov di,op_db
	call string_cmp
	and ax,ax
	jnz .op_dw

.op_db@loop
	mov si,word[pointer_read]
	mov di,buffer_bef1
	call parse_line
	add word[pointer_read],cx

	mov si,buffer_bef1
	lodsb

	mov di,word[pointer_write]

	and al,al
	jz near .end
	cmp al,0x27
	je .op_db@ascii

	dec si
	call format_numbers_8bit
	jc near .error_opcode

	mov byte[gs:di],al

	inc word[pointer_write]
	inc word[act_offset]

	jmp short .op_db@loop
.op_db@ascii
	lodsb

	cmp al,0x27
	je short .op_db@loop

	mov byte[gs:di],al
	inc di
	inc word[pointer_write]
	inc word[act_offset]

	jmp short .op_db@ascii
.op_dw
	mov di,op_dw
	call string_cmp
	and ax,ax
	jnz .op_dd

.op_dw@loop
	mov si,word[pointer_read]
	mov di,buffer_bef1
	call parse_line
	add word[pointer_read],cx

	mov si,buffer_bef1
	lodsb

	mov di,word[pointer_write]

	and al,al
	jz near .end

	dec si
	call format_numbers_16bit
	jc near .error_opcode

	mov word[gs:di],ax

	add word[pointer_write],2
	add word[act_offset],2

	jmp short .op_dw@loop
.op_dd
	mov di,op_dd
	call string_cmp
	and ax,ax
	jnz .op_org

.op_dd@loop
	mov si,word[pointer_read]
	mov di,buffer_bef1
	call parse_line
	add word[pointer_read],cx

	mov si,buffer_bef1
	lodsb

	mov di,word[pointer_write]

	and al,al
	jz near .end

	dec si
	call format_numbers_32bit
	jc near .error_opcode

	mov dword[gs:di],eax

	add word[pointer_write],4
	add word[act_offset],4

	jmp short .op_dd@loop
.op_org
	mov di,op_org
	call string_cmp
	and ax,ax
	jnz .op_int

	mov si,word[pointer_read]
	mov di,buffer_bef1
	call parse_line

	add word[pointer_read],cx

	cmp byte[failure],0
	jne near .error_opcode

	mov si,buffer_bef1
	call format_numbers_16bit
	jc near .error_opcode

	mov word[act_offset],ax
	mov word[act_org],ax

	jmp near .end
.op_int
	mov di,op_int
	call string_cmp
	and ax,ax
	jnz .op_pop

	mov si,word[pointer_read]
	mov di,buffer_bef1
	call parse_line
	add word[pointer_read],cx

	cmp byte[failure],0
	jne near .error_opcode

	mov si,buffer_bef1
	call format_numbers_8bit
	jc near .error_opcode

	mov di,word[pointer_write]
	mov ah,0xcd
	xchg al,ah
	mov word[gs:di],ax

	add word[pointer_write],2
	add word[act_offset],2

	jmp near .end
.op_pop
	mov di,op_pop
	call string_cmp
	and ax,ax
	jnz near .op_push

	mov si,word[pointer_read]
	mov di,buffer_bef1
	call parse_line
	add word[pointer_read],cx

	cmp byte[failure],0
	jne near .error_opcode

	jmp short .op_pop@asm
.op_pop@many_op
	mov si,word[pointer_read]
	mov di,buffer_bef1
	call parse_line
	add word[pointer_read],cx

	cmp byte[failure],0
	jne near .end
.op_pop@asm
	mov si,buffer_bef1

	call translate_16bit_reg
	cmp al,0xff
	jne .op_pop@reg16bit

	call translate_32bit_reg
	cmp al,0xff
	jne .op_pop@reg32bit

	call translate_seg_reg
	cmp al,0xff
	jne .op_pop@regseg

	push si
	mov di,op_word
	cmpsd
	pop si
	je near .op_pop@var_word

	push si
	mov di,op_dword
	mov cx,5
	rep cmpsb
	pop si
	je near .op_pop@var_dword

	jmp near .error_opcode
.op_pop@reg16bit
	add al,58h

	mov si,word[pointer_write]
	mov byte[gs:si],al
	inc word[pointer_write]
	inc word[act_offset]

	jmp near .op_pop@many_op
.op_pop@reg32bit
	add al,58h
	mov ah,66h
	xchg al,ah

	mov si,word[pointer_write]
	mov word[gs:si],ax
	add word[pointer_write],2
	add word[act_offset],2

	jmp near .op_pop@many_op
.op_pop@regseg
	mov si,word[pointer_write]

	and al,al
	jnz .op_pop@regseg@1

	mov byte[gs:si],07h
	inc word[pointer_write]
	inc word[act_offset]

	jmp near .op_pop@many_op
.op_pop@regseg@1
	cmp al,1
	jne .op_pop@regseg@2

	jmp near .error_opcode
.op_pop@regseg@2
	cmp al,2
	jne .op_pop@regseg@3

	mov byte[gs:si],17h
	inc word[pointer_write]
	inc word[act_offset]

	jmp near .op_pop@many_op
.op_pop@regseg@3
	cmp al,3
	jne .op_pop@regseg@4

	mov byte[gs:si],1fh
	inc word[pointer_write]
	inc word[act_offset]

	jmp near .op_pop@many_op
.op_pop@regseg@4
	cmp al,4
	jne .op_pop@regseg@5

	mov word[gs:si],0xa10f
	add word[pointer_write],2
	add word[act_offset],2

	jmp near .op_pop@many_op
.op_pop@regseg@5
	mov word[gs:si],0xa90f
	add word[pointer_write],2
	add word[act_offset],2

	jmp near .op_pop@many_op
.op_pop@var_word
	add si,4
	call test_clips
	cmp al,0xff
	je near .error_no_clips

	call look4label
	and al,al
	jnz near .error_label

	mov si,word[pointer_write]
	mov word[gs:si],0x068f
	add word[pointer_write],2
	add word[act_offset],2
	add si,2

	cmp bx,-1
	je near .op_pop@var_word@no_offset

	call .asm@offset

	jmp near .op_pop@many_op
.op_pop@var_word@no_offset
	mov al,1
	call add_offset2offset_table

	add word[pointer_write],2
	add word[act_offset],2

	jmp near .op_pop@many_op
.op_pop@var_dword
	add si,5
	call test_clips
	cmp al,0xff
	je near .error_no_clips

	call look4label
	and al,al
	jnz near .error_label

	mov si,word[pointer_write]
	mov byte[gs:si],66h
	inc si
	mov word[gs:si],0x068f
	add si,2
	add word[pointer_write],3
	add word[act_offset],3

	cmp bx,-1
	je near .op_pop@var_dword@no_offset

	call .asm@offset

	jmp near .op_pop@many_op
.op_pop@var_dword@no_offset
	mov al,1
	call add_offset2offset_table

	add word[pointer_write],2
	add word[act_offset],2

	jmp near .op_pop@many_op
.op_push
	mov di,op_push
	call string_cmp
	and ax,ax
	jnz near .op_mov

	mov si,word[pointer_read]
	mov di,buffer_bef1
	call parse_line

	add word[pointer_read],cx

	cmp byte[failure],0
	jne near .error_opcode

	jmp short .op_push@asm
.op_push@many_op
	mov si,word[pointer_read]
	mov di,buffer_bef1
	call parse_line
	add word[pointer_read],cx

	cmp byte[failure],0
	jne near .end
.op_push@asm
	mov si,buffer_bef1

	call translate_16bit_reg
	cmp al,0xff
	jne .op_push@reg16bit

	call translate_32bit_reg
	cmp al,0xff
	jne .op_push@reg32bit

	call translate_seg_reg
	cmp al,0xff
	jne .op_push@regseg

	mov di,op_byte
	call string_cmp
	and ax,ax
	jz near .op_push@num_byte

	push si
	mov di,op_word
	cmpsd
	pop si
	je near .op_push@var_word

	push si
	mov di,op_dword
	mov cx,5
	rep cmpsb
	pop si
	je near .op_push@var_dword

	jmp near .error_opcode
.op_push@reg16bit
	add al,50h

	mov si,word[pointer_write]
	mov byte[gs:si],al
	inc word[pointer_write]
	inc word[act_offset]

	jmp near .op_push@many_op
.op_push@reg32bit
	add al,50h
	mov ah,66h
	xchg al,ah

	mov si,word[pointer_write]
	mov word[gs:si],ax
	add word[pointer_write],2
	add word[act_offset],2

	jmp near .op_push@many_op
.op_push@regseg
	mov si,word[pointer_write]

	and al,al
	jnz .op_push@regseg@1

	mov byte[gs:si],06h
	inc word[pointer_write]
	inc word[act_offset]

	jmp near .op_push@many_op
.op_push@regseg@1
	cmp al,1
	jne .op_push@regseg@2

	mov byte[gs:si],0eh
	inc word[pointer_write]
	inc word[act_offset]

	jmp near .op_push@many_op
.op_push@regseg@2
	cmp al,2
	jne .op_push@regseg@3

	mov byte[gs:si],16h
	inc word[pointer_write]
	inc word[act_offset]

	jmp near .op_push@many_op
.op_push@regseg@3
	cmp al,3
	jne .op_push@regseg@4

	mov byte[gs:si],1eh
	inc word[pointer_write]
	inc word[act_offset]

	jmp near .op_push@many_op
.op_push@regseg@4
	cmp al,4
	jne .op_push@regseg@5

	mov word[gs:si],0xa00f
	add word[pointer_write],2
	add word[act_offset],2

	jmp near .op_push@many_op
.op_push@regseg@5
	mov word[gs:si],0xa80f
	add word[pointer_write],2
	add word[act_offset],2

	jmp near .op_push@many_op
.op_push@var_word
	add si,4

	lodsb
	dec si
	and al,al
	jz near .op_push@num_word

	call test_clips
	cmp al,0xff
	je near .error_no_clips

	call look4label
	and al,al
	jnz near .error_label

	mov si,word[pointer_write]
	mov word[gs:si],0x36ff
	add word[pointer_write],2
	add word[act_offset],2
	add si,2

	cmp bx,-1
	je near .op_push@var_word@no_offset

	call .asm@offset

	jmp near .op_push@many_op
.op_push@var_word@no_offset
	mov al,1
	call add_offset2offset_table

	add word[pointer_write],2
	add word[act_offset],2

	jmp near .op_push@many_op
.op_push@var_dword
	add si,5

	lodsb
	dec si
	and al,al
	jz near .op_push@num_dword

	call test_clips
	cmp al,0xff
	je near .error_no_clips

	call look4label
	and al,al
	jnz near .error_label

	mov si,word[pointer_write]
	mov byte[gs:si],66h
	inc si
	mov word[gs:si],0x36ff
	add si,2
	add word[pointer_write],3
	add word[act_offset],3

	cmp bx,-1
	je near .op_push@var_dword@no_offset

	call .asm@offset

	jmp near .op_push@many_op
.op_push@var_dword@no_offset
	mov al,1
	call add_offset2offset_table

	add word[pointer_write],2
	add word[act_offset],2

	jmp near .op_push@many_op
.op_push@num_byte
	mov si,word[pointer_read]
	mov di,buffer_bef2
	call parse_line
	add word[pointer_read],cx

	cmp byte[failure],0
	jne near .error_opcode

	mov si,buffer_bef2
	call format_numbers_8bit
	jc near .error_opcode

	mov si,word[pointer_write]
	mov ah,6ah
	xchg al,ah

	mov word[gs:si],ax
	add word[pointer_write],2
	add word[act_offset],2

	jmp near .end
.op_push@num_word
	mov si,word[pointer_read]
	mov di,buffer_bef2
	call parse_line
	add word[pointer_read],cx

	cmp byte[failure],0
	jne near .error_opcode

	mov si,buffer_bef2
	call format_numbers_16bit
	jc near .error_opcode

	mov si,word[pointer_write]

	mov byte[gs:si],68h
	inc si
	mov word[gs:si],ax
	add word[pointer_write],3
	add word[act_offset],3

	jmp near .end
.op_push@num_dword
	mov si,word[pointer_read]
	mov di,buffer_bef2
	call parse_line
	add word[pointer_read],cx

	cmp byte[failure],0
	jne near .error_opcode

	mov si,buffer_bef2
	call format_numbers_32bit
	jc near .error_opcode

	mov si,word[pointer_write]

	mov word[gs:si],0x6866
	add si,2
	mov dword[gs:si],eax
	add word[pointer_write],6
	add word[act_offset],6

	jmp near .end
.op_mov
	mov di,op_mov
	call string_cmp
	and ax,ax
	jnz near .op_jmp

	mov si,word[pointer_read]
	mov di,buffer_bef1
	call parse_line
	add word[pointer_read],cx

	mov si,word[pointer_read]
	mov di,buffer_bef2
	call parse_line
	add word[pointer_read],cx

	cmp byte[failure],0
	jne near .error_opcode

	mov si,buffer_bef1
	call translate_8bit_reg
	cmp al,0xff
	jne near .op_mov@reg_var_byte

	call translate_16bit_reg
	cmp al,0xff
	jne near .op_mov@reg_var_word

	call translate_32bit_reg
	cmp al,0xff
	jne near .op_mov@reg_var_dword

	call translate_seg_reg
	cmp al,0xff
	jne near .op_mov@seg_reg

	push si
	mov di,op_byte
	cmpsd
	pop si
	je near .op_mov@reg_var_byte

	push si
	mov di,op_word
	cmpsd
	pop si
	je near .op_mov@reg_var_word

	push si
	mov di,op_dword
	mov cx,5
	rep cmpsb
	pop si
	je near .op_mov@reg_var_dword

	push si
	mov di,reg_dr
	cmpsw
	pop si
	je .op_mov@dr_reg

	push si
	mov di,reg_cr
	cmpsw
	pop si
	je .op_mov@cr_reg

	jmp near .error_opcode
.op_mov@dr_reg
	add si,2
	lodsb
	and al,al
	jz near .error_opcode
	cmp al,'7'
	jg near .error_opcode
	cmp al,'0'
	jl near .error_opcode
	mov dl,al
	lodsb
	and al,al
	jnz near .error_opcode

	mov si,buffer_bef2
	call translate_32bit_reg
	cmp al,0xff
	je near .error_opcode

	push ax
	mov al,dl
	call ascii_char2hex
	mov dl,al
	pop ax

	shl dl,3
	or al,dl
	or al,11000000b
	mov si,word[pointer_write]
	mov word[gs:si],0x230f
	add si,2
	mov byte[gs:si],al
	add word[pointer_write],3
	add word[act_offset],3

	jmp	near .end
.op_mov@cr_reg
	add si,2
	lodsb
	and al,al
	jz near .error_opcode
	cmp al,'4'
	jg near .error_opcode
	cmp al,'0'
	jl near .error_opcode
	mov dl,al
	lodsb
	and al,al
	jnz near .error_opcode

	mov si,buffer_bef2
	call translate_32bit_reg
	cmp al,0xff
	je near .error_opcode

	push ax
	mov al,dl
	call ascii_char2hex
	mov dl,al
	pop ax

	shl dl,3
	or al,dl
	or al,11000000b
	mov si,word[pointer_write]
	mov word[gs:si],0x220f
	add si,2
	mov byte[gs:si],al
	add word[pointer_write],3
	add word[act_offset],3

	jmp	near .end
.op_mov@seg_reg
	mov dl,al

	mov si,buffer_bef2
	call translate_16bit_reg
	cmp al,0xff
	jne .op_mov@seg_reg@reg

	mov di,op_word
	cmpsd
	jne near .error_opcode
.op_mov@seg_reg@var
	call test_clips
	and al,al
	jnz near .error_no_clips

	call look4label
	and al,al
	jnz near .error_label

	mov si,word[pointer_write]

	shl dl,3
	or dl,6
	mov byte[gs:si],0x8e
	inc si
	mov byte[gs:si],dl
	inc si
	add word[pointer_write],2
	add word[act_offset],2

	cmp bx,-1
	je .op_mov@seg_reg@var@no_offset

	call .asm@offset

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -