; Complete objectives: 1.;: show green, green background of red, blue and white string "welcome to masm!" In the middle of the screen; others need to know knowledge
memory space, B8000H-BFFFFH total of 32KB of space for the 80X25 color display buffer character-mode, data is written to this address space, the data will be written to stand the mountain appears in the display.
; 1. The display shows 25 lines of 80 characters, each of which can have 256 properties. ; 2.
a character display buffer must two bytes, and attributes are stored in ASCII characters. ; 3. contents in a screen display buffer 4000 bytes representing the CCP.
80x25 = 2000; 4. a byte, the lower byte stored in the ASCII character code, character attribute high byte storage. ; 5. The 2. 7. 6. 5. 4. 3. 1 0
; BL RGBIRGB; flashing highlight background color foreground;; 6: green on black: 0000 0010B => 02H;
flashing green background +: 1010 0100B => A4H; blue on white: 0111 0001B => 71H;; 7. the 'available for purchase
to MASM!' corresponding hexadecimal: 77H, 65H, 6CH, 63H, 6FH, 6DH, 65H, 20H, 74H, 6F,
20H, 6DH, 61H, 73H, 6D, 21H. ; 7. flickering effect must be seen in full-screen DOS.
My code appeared little bug, seemingly can only display two lines of
the ASSUME ds: the Data, cs: code, SS: Stack
the Data segment
'! Is available for purchase to MASM' db
db 00000010b, 00100100b, 10001001b, 0,0,0,0 , 0,0,0,0,0,0,0,0,0; benefits of using the segmented data
; each cycle time can be as long as the corresponding data call
; this is a color field
DW 160. 12 is 64,160 + 13 is * 64,160 + 14 + 64,0,0,0,0,0
; plus intermediate position 64 as a program, is multiplied by the number of rows offset amount to give a final start address
; this data offset field
data ends
stack segment
dw 0,0,0,0,0,0,0,0
stack ends
code segment
start:mov ax,stack
mov ss,ax
;ss = 076d
mov sp,0010h
;sp = 0010h
mov ax,data
;让ax保存程序数据的起始地址
;ax = 076ah
mov cx,3
;cx = 0003
mov di,0
;di = 0000
s1:push cx;076d:000e = 0003
mov si,ax
;si = 076ah
inc si;ax挪移一格
;si = 076bh
mov es,si;程序打到颜色字段部分
;es = 076bh
mov dl,es:[di]
;dl负责保存颜色字段
;dl = 02h
mov si,ax
inc si
inc si;ax挪移两格
mov es,si;段地址为偏移量字段
;es = 076c
mov bp,es:[di]
;bp负责保存偏移量字段
;bp = 0780
;将076c:0000中的值放入bp中
;即bp = 07c0
mov cx,16
;cx = 0010
mov si,0;内层循环所用数据
;si = 0000
mov es,ax;es中存放data的地址
;es = 076ah
inc di
s2:mov bx,0b800h
mov ds,bx
;ds = 0b800h
mov bl,es:[si];将相应的asc码存放入相应的地址
;将076a:0000中的值放入bl之中
;位置:ip = 0031,bl = 77
mov ds:[bp],bl
;将bl = 77中的值放入b800:07c0中去
;ip = 0034
;ip = 0034位置程序出现bug的位置!!!!!!!!!
inc bp
mov ds:[bp],dl;dl负责保存颜色字段,将颜色放入第二位
inc bp
inc si;进入下一个数据的asc码
loop s2
pop cx
loop s1
mov ax,4c00h
int 21h
code ends
end start
It found to occur after the last finish running bug, only one is displayed twice, shows little cycle, the second cycle after the data is seemingly did not turn in the address you want? Ip = 0034 start from
here trying to data bl is stored in the b800: location 07c0, and have not yet run this statement, let's look at b800: data 07c0 location of
problems with the program, followed by a program run ds: 07c0 = 20, but the view b800: 07c0 location data but for 63
Next we look after running the program if there are problems
here and there is a problem, originally bx = b877, bl = 77, but after running the data
number memory was changed to 30, indicating that by looking at memory You can not view the way to the correct value into the display area, the reason I think dos display is constantly changing, so the memory can not be displayed correctly display the corresponding data.
Here I venture to guess, the data should be stored in the display to go to the other locations, and each time the assignment finish line will be normal, because here after the program finishes running normally still be able to display data