| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| This is a piece of code from a tutorial that i got on the net.But i cant understand what is the code for. <code>Procedure ClearScreen(A : Byte; Ch : Char); Assembler; Asm { ClearScreen } mov ax, 0B800h mov es, ax xor di, di mov cx, 2000 mov ah, A mov al, &Ch rep stosw End; { ClearScreen }</code> Is this the code for function clear screen in asm |
|
#2
| |||
| |||
| palbodhisattwa2016 wrote: > This is a piece of code from a tutorial that i got on the net.But i > cant understand what is the code for. > <code>Procedure ClearScreen(A : Byte; Ch : Char); Assembler; > > Asm { ClearScreen } > mov ax, 0B800h > mov es, ax > xor di, di > mov cx, 2000 > mov ah, A > mov al, &Ch > rep stosw > End; { ClearScreen }</code> > Is this the code for function clear screen in asm Yes, it clears the screen to a given character and attribute. It loads a pointer to the video buffer into ES (B800), puts an initial offset of 0 into DI, loads a count of 2000 into CX, the character and attribute into AX, and then stores AX at the location pointed to by ES I, and increments DI and repeats for the number of times in CX withthe "stosw" instruction. Get the x86 manuals from Intel's website and look up all the instructions you don't understand. Bjarni -- INFORMATION WANTS TO BE FREE |
|
#3
| |||
| |||
| I want to know that why the pointer to the vedio buffer B800 is loaded into the ax first and then it is loaded into the es register.And how the offset of 0 is loaded inti di.I mean that can you explain thjat xor di,di in more details.I know the trurh table of Or is 0 or 0=0 0 or 1=1 1 or 0=1 1 or 1=1 and XOR will be 1 0 0 0.............correspondingly. |
|
#4
| |||
| |||
| On Sat, 30 Aug 2008 12:54:47 -0700 (PDT), palbodhisattwa2016 <spamtrap@crayne.org> wrote: >I want to know that why the pointer to the vedio buffer B800 is >loaded into the ax first and then it is loaded into the es >register.And how the offset of 0 is loaded inti di.I mean that can you >explain thjat xor di,di in more details.I know the trurh table of Or >is >0 or 0=0 >0 or 1=1 >1 or 0=1 >1 or 1=1 >and XOR will be >1 >0 >0 >0.............correspondingly. "xor di,di" is a standard shortcut way of zeroing out a register. On the x86 platform is also has side effects of changing some of the flag bits. If you need to zero out a register without the side effects, use "mov di,0" BTW, these are EXTREEMLY basic asm operations. If you don't understand them, I would suggest a beginners asm book. -- ArarghMail808 at [drop the 'http://www.' from ->] http://www.arargh.com BCET Basic Compiler Page: http://www.arargh.com/basic/index.html To reply by email, remove the extra stuff from the reply address. |
|
#5
| |||
| |||
| palbodhisattwa2016 <spamtrap@crayne.org> writes: > I want to know that why the pointer to the vedio buffer B800 is > loaded into the ax first and then it is loaded into the es > register. Can you, after you've looked at the instruction set, suggest a better way? > And how the offset of 0 is loaded inti di.I mean that can you > explain thjat xor di,di in more details.I know the trurh table of Or > is > 0 or 0=0 > 0 or 1=1 > 1 or 0=1 > 1 or 1=1 > and XOR will be > 1 > 0 > 0 > 0.............correspondingly. Nope, that's NOR. XOR is eXclusive OR - {00,11}->0, {01,10}->1. Phil -- The fact that a believer is happier than a sceptic is no more to the point than the fact that a drunken man is happier than a sober one. The happiness of credulity is a cheap and dangerous quality. -- George Bernard Shaw (1856-1950), Preface to Androcles and the Lion |
|
#6
| |||
| |||
| Am Sat, 30 Aug 2008 12:54:47 -0700 (PDT) schrieb palbodhisattwa2016: > I want to know that why the pointer to the vedio buffer B800 is > loaded into the ax first and then it is loaded into the es > register. It isnīt possible to load a segment-register(segreg) with a immidiate operand. Beside the way to load a segreg with a 16 bit base-register, it is possible to load both the segment- and the offset-register in one operation. les di, [MEM] MEM DW 0, 0B800h Dirk |
|
#7
| |||
| |||
| "palbodhisattwa2016" asked: > This is a piece of code from a tutorial that i got on the net.But i > cant understand what is the code for. > <code>Procedure ClearScreen(A : Byte; Ch : Char); Assembler; > Asm { ClearScreen } > mov ax, 0B800h > mov es, ax > xor di, di > mov cx, 2000 > mov ah, A > mov al, &Ch > rep stosw > End; { ClearScreen }</code> > Is this the code for function clear screen in asm If your &Ch in AL is a space (20h) and the A in AH an attribute pattern with a black background (ie: 07h) then it will clear the screen (even only valid for texmode 03). Other parameters may fill the screen with whatsoever and may also blink and/or underline with different foreground/background colors. As Dirk already said there is no instruction like MOV es,imm16 available, so if codesize or register usage is an issue you can also use the shorter but slower push b800h pop es. ______________ (ie: without parameters over stack) CLS: MOV ax,0720h ;or make it reverse with 7020h FillScreen: ;set ax as desired to call this MOV cx,2000 PUSH 0b800h POP es XOR di,di REP STOSW RET _______________ Find all required info on Textmode Attributes in RBIL. __ wolfgang |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.