Lab1_var1 asm SECTION PM seg_pmco GLOBAL _main _main NOP PX1 DM 0x0400

  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
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
/*****************************************************************************
* Lab1_var1.asm
*****************************************************************************/
.SECTION/PM seg_pmco;
.GLOBAL _main;
_main:
NOP;
PX1 = DM(0x040000); //Óçíà¸ì ñêîëüêî îòðåçêîâ â ïàìÿòè
I0 = 0x040001; //C ýòîãî àäðåñà íà÷èíàþòñÿ êîîðäèíàòû îòðåçêîâ
R4 = PX1; //êîë-âî îòðåçêîâ â R4
R5 = 0;
R6 = 1;
COMP(R4, R5);
IF EQ JUMP NO_LINES; //Âõîäíîé ìàññèâ òî÷åê ïóñò
//Àäðåñ êîíöà áóôåðà êîîðäèíàò òî÷åê (âûõîäíûå äàííûå)
I1 = 0x041000;
PX1 = DM(0, I0); //Xstart
R0 = PX1;
PX1 = DM(1, I0); //Ystart
R1 = PX1;
PX1 = DM(2, I0); //Xend
R2 = PX1;
PX1 = DM(3, I0); //Yend
R3 = PX1;
R5 = I0;
R7 = 4;
R5 = R5 + R7;
I0 = R5;
R6 = 1;
COMP(R4, R6); //Ïðîâåðÿåì, ðàâíî ëè êîë-âî ëèíèé 1
IF EQ JUMP ONE_LINE;
R4 = R4 - 1; //Ïîñëåäíÿÿ îáðàáîòêà áóäåò âíå öèêëà
LCNTR = R4;
DO ENDOFLINECOMP UNTIL LCE;
CALL Bresenham_algo;
PX1 = DM(0, I0); //Xstart
R0 = PX1;
PX1 = DM(1, I0); //Ystart
R1 = PX1;
PX1 = DM(2, I0); //Xend
R2 = PX1;
PX1 = DM(3, I0); //Yend
R3 = PX1;
R5 = I0;
R6 = 4;
R5 = R5 + R6;
I0 = R5;
ENDOFLINECOMP: R3 = PX1;
ONE_LINE:
CALL Bresenham_algo;
NO_LINES:
IDLE;
Bresenham_algo:
R4 = R2 - R0; // Delta X
R5 = R3 - R1; // Delta Y
R6 = ABS R4; // | Delta X |
R7 = ABS R5; // | Delta Y |
R8 = 0;
OCT1:
R4 = 0; //ERROR
R5 = R1; // Y = Ystart
LCNTR = R6;
DO OCT1_TRACE_END UNTIL LCE;
PX1 = CURLCNTR;
DM(0, I1) = PX1; // Çàïèñûâàåì Õ òî÷êè
PX1 = R5;
DM(1, I1) = PX1; //Çàïèñûâàåì Y òî÷êè
R8 = I1;
R9 = 2;
R8 = R8 + R9;
I1 = R8;
R4 = R4 + R5; // ERROR = ERROR + |Delta Y|
R8 = LSHIFT R4 BY 1; //ERROR*2
COMP(R8, R4); // ERROR*2 >= |Delta X| ?
IF GE R5 = R5 + 1; // Y = Y + 1;
OCT1_TRACE_END:
IF GE R4 = R4 - R6; // ERROR = ERROR - |Delta X|
OCT2:
OCT3:
OCT4:
OCT5:
OCT6:
OCT7:
OCT8:
RTS;
._main.END: