matrix.asm

来自「介绍用Java解析网络数据的三种特殊方法」· 汇编 代码 · 共 74 行

ASM
74
字号
; Matrix transpose sample
; (reverse rows with columns).


#make_COM#

ORG 100h

jmp start

; To view matrix select
; "Variables" from "View"
; menu of the emulator
; and set [Elements] property
; to "3" for these items:
;   MATRIX
;   ROW1
;   ROW2

matrix_size EQU 3

; ----- matrix ------
matrix     db 1,2,3
row1       db 4,5,6
row2       db 7,8,9
;--------------------

i dw ?
j dw ?

start:

mov i, 0
next_i:

	; j = i + 1
	mov cx, i
	inc cx
	mov j, cx
	next_j:
	
		MOV SI, i
		MOV BX, j
	
		MOV AL, matrix_size
		MOV CX, SI
		MUL CL
		MOV SI, AX	
		MOV DL, matrix[SI][BX]
		
		MOV SI, i
		MOV AL, matrix_size
		MUL BL
		MOV BX, AX
		XCHG matrix[BX][SI], DL
		
		MOV BX, j
		MOV AL, matrix_size
		MOV CX, SI
		MUL CL
		MOV SI, AX
		MOV matrix[SI][BX], DL
	
	INC j
	CMP j, matrix_size
	JB next_j	
INC i
CMP i, matrix_size/2
JBE next_i

ret

end

⌨️ 快捷键说明

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