Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ORG 0h
- %define _ScreenWidth 80
- %define _ParamOffset (4+16+2+2) ;(CS/IP)+PUSHA+ES+DS
- %define _RectX BP+_ParamOffset+12
- %define _RectY BP+_ParamOffset+10
- %define _RectWid BP+_ParamOffset+8
- %define _RectHei BP+_ParamOffset+6
- %define _TxtBlock BP+_ParamOffset+4
- %define _BuffSeg BP+_ParamOffset+2
- %define _BuffAddr BP+_ParamOffset+0
- Start:
- PUSHA ;16 bytes
- PUSH ES ;2 bytes
- PUSH DS ;2 bytes
- MOV BP, SP
- ;Start pos on buffer is [RectX + (RectY*ScreenWidth)] << 1
- MOV BX, WORD [_RectY] ;Get RectY
- IMUL AX, BX, _ScreenWidth ;Multiply by ScreenWidth and store result in AX
- ADD AX, WORD [_RectX] ;Add RectX
- SHL AX, 1 ;2 bytes per character block
- MOV DI, WORD [_BuffAddr] ;Set DI to start of buffer
- ADD DI, AX ;DI is now top left corner of rectangle
- MOV CH, BYTE [_RectHei] ;Counter for drawing rows
- MOV CL, BYTE [_RectWid] ;Counter for position in row
- MOV DX, _ScreenWidth ;How much to add to get to next line
- SUB DL, CL ;DL = ScreenWidth - RectWid
- SHL DX, 1 ;2 bytes per character block
- MOV AX, WORD [_TxtBlock] ;Character we'll draw the rectangle with
- MOV DS, WORD [_BuffSeg] ;Load buffer segment
- ;Buffer is DS:DI
- MOV BL, CL ;Backup X counter in BL
- NextY:
- MOV CL, BL
- NextX:
- MOV [DI], AX ;Write a character to the buffer
- ADD DI, 2 ;Update buffer pointer
- DEC CL ;One character, still more?
- JNZ NextX ;Yes? draw the next one
- ADD DI, DX ;Adjust pointer to next row
- DEC CH ;Done one line, still more?
- JNZ NextY ;Yes? Go back until done
- End:
- POP DS
- POP ES
- POPA
- RETF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement