Assembler in DOS.
category: code [glöplog]
strange thing. ive seen some intros using this code:
when i compile and link my final .com looks like this:
why is that?
its smaller just using two mov's :P
is it the compiler that is bloated or am i missing something?
Code:
push 0a000h
pop es
when i compile and link my final .com looks like this:
Code:
00000000 50 push ax
00000001 55 push bp
00000002 8BEC mov bp,sp
00000004 C7460200B8 mov word [bp+0x2],0xa000
00000009 5D pop bp
0000000A 07 pop es
why is that?
its smaller just using two mov's :P
is it the compiler that is bloated or am i missing something?
i imploded it. but its still 4 bytes.
68 00 A0 07
opposed to:
B4 A0 8E C0
:/
68 00 A0 07
opposed to:
B4 A0 8E C0
:/
68 00 A0 - push word 0a000h
07 - pop es
B4 A0 - mov ah,0a0h
8E C0 - mov es,ax
07 - pop es
B4 A0 - mov ah,0a0h
8E C0 - mov es,ax
sorry, the listing shouldve been like this:
C7460200A0 mov word [bp+0x2],0xa000
i used textmode forgot to change the opcodes for clearer readability like 0A000..
C7460200A0 mov word [bp+0x2],0xa000
i used textmode forgot to change the opcodes for clearer readability like 0A000..
Quote:
when i compile
When you compile *what*?
And with what compiler? With what options?
turbo assembler 3.2:
tasm.exe src.asm
tlink.exe /t src.obj
simple as that...
tasm.exe src.asm
tlink.exe /t src.obj
simple as that...
rudi, you must enable 80286 code. By default TASM compiles for 8086. But 8086 does not support push 0a000h pop es. Write
at the beginning of your program and it will work. (You could also write .386, .486 or .586...)
Code:
.286
at the beginning of your program and it will work. (You could also write .386, .486 or .586...)
yea, thanks adok. it worked.
Don't forget the coolest asm instruction ever: xlat
BTW, this thread has number 8088. Cool, isn't it? :) 8088 was the CPU of the very first PCs in the early 1980s.
yay, i didnt notice :)
Rudi have you tried FASM? has DOS version(with IDE) if you are coding in a pure DOS environment.
rudi, but the "mov ah, 0a0h" version requires al to be zero!
NOOOOOOOOOOOOOOOOOT safe
OMG! Unsafe demo code! ;)
There are also some ways to put pixels with the "mov ah,0a0h version" even if AL is not zero. You must keep in mind that physical address = segment * 16 + offset. If you want to put a pixel to position x,y you usually calculate offset = y*320 + x (provided you are in screen mode 13h). But if the segment is not equal to 0a000h, then the offset must be calculated in a different way, depending on the difference of the segment to 0a000h (which is the value of AL when you write mov ah,0a0h mov es,ax). Let's say the difference is d, then you must subtract d*16 from the offset. This, however, implies that you cannot put pixels to the positions where the offset would be lower than d*16 if the segment were 0a000h. I used that trick in my 256b intro Indian Summer (source code is included in the archive).
Hehe at first I was at a loss as well about that could be about but yeah, processor indications on top of your .asm files are pretty standard fare. Though I must admit I find it a tad weird that unsupported assembler (given the assumed platform) is intrinsicly expanded into that. I mean sure this is kind of a volatile topic since well.. what exactly is the right heuristic on what en where to enable silent/intrinsical expansion/implosion of code but I think that a straight assembler shouldn't do this. Anyone agree or?
that->what
(and I've used Tasm for many years..)
i tried accessing the bios fonts, to manipulate them, but im not sure if i got the correct address. do they lie in segment F000? and index FA6E?
so if i where to change character 'a' which is ascii-code 97, wouldnt this be right to do:
i did not find much documentation about the bios fonts on the net. but i found the addresses F000:FA6E though im not sure if that is correct. also isnt the rest of above code right (if you take for granted that filesize is not important here) ?
so if i where to change character 'a' which is ascii-code 97, wouldnt this be right to do:
Code:
mov ax,0F000h
mov es,ax
mov ax,0FA6Eh
add ax,97*8 ;FA6E + 97*8 (since each char takes 8 bytes)
mov di,ax
mov al,22h ;new bit-pattern for character 'a'.
stosb ;store al at es:di
ret
i did not find much documentation about the bios fonts on the net. but i found the addresses F000:FA6E though im not sure if that is correct. also isnt the rest of above code right (if you take for granted that filesize is not important here) ?
also, does dosbox support bios font manipulation? i heard from earlier versions that dosbox had bitmapped fonts, but i dont know if that means that their not in the bios.
rudi: There was an article about "Manipulating the BIOS font" in Hugi 12.
ok, cool. ill check it out
imagine more "aargh" here.
you don't manipulate the bios font. the bios font is in ROM (well, or used to be anyway, a long time ago :).
anyway, the point is this: the bios font's only purpose is to be uploaded to the the right region of video memory on a mode change.
if you want to modify the active text mode font, you can change that region.
you don't manipulate the bios font. the bios font is in ROM (well, or used to be anyway, a long time ago :).
anyway, the point is this: the bios font's only purpose is to be uploaded to the the right region of video memory on a mode change.
if you want to modify the active text mode font, you can change that region.
ryg: :) of course. i felt a little retarded after posting that code, because i was a little too fast. i wonder where i can change the position of that region though. ive found some more docs on the matter, but holy crap there's so much weird services out there. :P