flat assembler
Message board for the users of flat assembler.
Index
> DOS > segments |
Author |
|
decard 22 Jul 2004, 15:45
The code that you attached will compile as binary (*.com) file. Actually COM programs are placed into memory at 0x100 offset, so you have to specify it with ORG directive, and your program should look like this:
Code: jmp start variable1 db 25 start: mov ax,variable1 jmp $ in COM programs all segment registers (CS, DS, ES), are set to the same value, there's common segment for both code and data. In memory it will look likt this: Code: 0100 jmp start 0103 variable1 db 25 0104 mov ax,variable1 0105 jmp $ |
|||
22 Jul 2004, 15:45 |
|
Bitdog 05 Sep 2004, 05:48
JMP $ ;endless loop to it'self = oops
you are jumping to the JMP address ? For what? |
|||
05 Sep 2004, 05:48 |
|
crc 05 Sep 2004, 10:34
Quote: JMP $ ;endless loop to it'self = oops It's a good way to halt the entire system under DOS or in a single-tasking OS |
|||
05 Sep 2004, 10:34 |
|
vid 06 Sep 2004, 14:46
vertex: try my tutorial, it is not fully descrtibed but you may learn something
|
|||
06 Sep 2004, 14:46 |
|
hartyl 06 Sep 2004, 18:46
crc wrote:
when entering ring0 in a OS like windows, you can do a Code: cli jmp $ to hang the system |
|||
06 Sep 2004, 18:46 |
|
Matrix 20 Sep 2004, 09:03
that is not enough on my windos,
you must do this: Code:
.mainloop:
cli
jmp .mainloop
but if you prefer you can do this: Code: mov ss,ax times 30 push $1234 you needn't try hard to make your machine hang or reset, i have discovered many ways mysef. MATRIX |
|||
20 Sep 2004, 09:03 |
|
izhbq412 21 Oct 2004, 06:24
Quote: If i am on the right track with both of those then does that mean that if DS does not point to your data segment then you program will not be able to access your variables correctly right? I guess so. Acutally this doesn't work: Code: format MZ entry .code:start stack 100h segment .code use16 start: nop mov ax, [b] mov ax, 4C00h int 21h segment .data use16 b dw 5 Code: AX=0000 BX=FFFF CX=FE32 DX=0000 SP=0100 BP=0000 SI=0000 DI=0000 DS=0C1C ES=0C1C SS=0C2E CS=0C2C IP=0001 NV UP EI PL NZ NA PO NC 0C2C:0001 A10000 MOV AX,[0000] DS:0000=20CD So after mov ax, [b] is executed the value in AX becomes 20CD, not 5. As this is not a .com executable there is no org 100h required as far as I know. If I move the data definition in the .code segment and use [cs:b] instead of [b] it works just fine. I've just started writing in assembler (I've been reading assembler and writing inline asm code in C++ for quite some time, never really programmed complete asm programs though) and this is the first serious problem I can't handle by myself EDIT: Hehe, I handled it after all Had to load .data to a general register and then mov to ds _________________ The essence of balance is detachment. To embrace a cause, to grow fond or spiteful, is to lose one's balance after which, no action can be trusted. Our burden is not for the dependent of spirit. -- Mayar, Third Keeper |
|||
21 Oct 2004, 06:24 |
|
JohnFound 21 Oct 2004, 06:52
if your data is in different segment, you have to set proper values of the segment registers. This should work:
Code: format MZ entry codeseg:start segment codeseg start: push codeseg ; or mov ax, codeseg ; mov ds, ax pop ds mov ax, [b] mov ax, 4C00h int 21h segment dataseg b dw 5 btw: IMHO, using "." as prefix for segment names is not a good idea, because "." in FASM defines local labels. Regards. |
|||
21 Oct 2004, 06:52 |
|
bubach 21 Oct 2004, 08:09
That tutorial seems really good! Do you mind if i put it on my website? I'll keep all copyrights intact, of course...
/ Christoffer Last edited by bubach on 13 Feb 2012, 14:14; edited 1 time in total |
|||
21 Oct 2004, 08:09 |
|
izhbq412 21 Oct 2004, 08:15
Which one is faster:
Code: push dataseg pop ds or Code: mov ax, dataseg mov ds, ax ? Or is it exactly the same? Quote: btw: IMHO, using "." as prefix for segment names is not a good idea, because "." in FASM defines local labels. Shte go imam predvid (V tozi forum ne mi izliza kirilicata ) _________________ The essence of balance is detachment. To embrace a cause, to grow fond or spiteful, is to lose one's balance after which, no action can be trusted. Our burden is not for the dependent of spirit. -- Mayar, Third Keeper |
|||
21 Oct 2004, 08:15 |
|
Matrix 21 Oct 2004, 08:47
Hello,
since i used to do some size / speed optimizations somewhat i can help: stack is in memory, if its not cached then its about 290MB/s on my machine push AX = mov [ss:sp],AX sub sp,2 pop AX = mov AX,[ss:sp] add sp,2 there is no such push pop, but you can do it 1 bytes push AL = mov [ss:sp],AL dec sp pop AL = mov AL,[ss:sp] inc sp my L2 cache is about 4.5 GB/s, L1 is 9.5GB/s, and my CPU's registers are very fast, many times faster then memory. this is small in size, and not usingy registers, but its slow Code: push dataseg pop ds or however this is larger in code and uses a register Code: mov ax, dataseg mov ds, ax so when i can do it, and there are mass calculations to do, i prefer registers. |
|||
21 Oct 2004, 08:47 |
|
izhbq412 21 Oct 2004, 17:04
I see. Thank you
|
|||
21 Oct 2004, 17:04 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.