real mode dos assembly trouble
Well how it is goin', Zacariaz? Did the helloworld example compiled successfully?
Note: Do not try to attempt to write registers values on the screen using ASM for now, try something easier like hello world program that asks for a keyboard input, and then it will echo back with the string If you need help, just ask
Regards
inflater
Note: Do not try to attempt to write registers values on the screen using ASM for now, try something easier like hello world program that asks for a keyboard input, and then it will echo back with the string If you need help, just ask
Regards
inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Hello world is the easiest thing in the world and works perfectly.inflater wrote:Well how it is goin', Zacariaz? Did the helloworld example compiled successfully?
Note: Do not try to attempt to write registers values on the screen using ASM for now, try something easier like hello world program that asks for a keyboard input, and then it will echo back with the string If you need help, just ask
Regards
inflater
Remember that im not stupid, actually im fairly intelligent, however, the structure can be difficult, especially in ASM where the structure varies from different assemblers. just condider intel vs. AT&T suntax...
I have always loved the step-step-by-concept of ASM, but never really got started.
I was actually thinking about constuction a program which prints every prime number from 0x0 - 0xffff. The structure of the program should be too difficult, however i would need some sort of searchable stack or vector or simular, and that is... well im thinking about that
Com to think about it i believe i asked a related question with some example code at some time at programmersheaven... ill post a link if i find it and it doesnt imbaress me too much
Your code seems fine for me...
Anyways, you can use INT 20h instead of END. What assembler are you using?
Overflow handling? I suggest hooking a custom ISR to INT 0 (I highly recommend to read on DOS's INT 21h and to not use BIOS = if you exit from your program, you would run some GUI program that caused overflow, and it will trigger INT 0... and you realize that your INT0 ISR had a "jmp ExitFromIsrToMainProgram"... ehh, the result can be highly predictable ). If you would use BIOS, MS-BOSS wouldn't have idea that the INT0 has changed...
Yes you do not need to MOV EDX,0, if you are changing the EDX right after it. Its quite simple, but harder to tell -> if you MOVe something to a register, it will automatically erase everything that is stored on the destination (register), and replace it with contents specified as the second operand (source, in the INTEL syntax). But if you have some high number stored in EDX (full 32bit number, like 0FFFFFFFFh), and you would just do MOV DX, 5, I think the CPU will leave the 32bit part "as it is"... Correct me if this is wrong please.
By the way, 0x2 is the same as 2, and 0x0 is the same as XORing the same register with the same (it is faster as you already know, but noticeable maybe only on eerly 8086/80186/V30 etc. ), or 0x0 = 0 simply. Save two bytes of "0x" in your asm code
JNE means "jump if not eqal", you are right , so if CMP EDX,0 ; JNE NOTPRIME would jump to label NOTPRIME if EDX is not 0. I think you already know that
Regards
inflater
Anyways, you can use INT 20h instead of END. What assembler are you using?
Overflow handling? I suggest hooking a custom ISR to INT 0 (I highly recommend to read on DOS's INT 21h and to not use BIOS = if you exit from your program, you would run some GUI program that caused overflow, and it will trigger INT 0... and you realize that your INT0 ISR had a "jmp ExitFromIsrToMainProgram"... ehh, the result can be highly predictable ). If you would use BIOS, MS-BOSS wouldn't have idea that the INT0 has changed...
Yes you do not need to MOV EDX,0, if you are changing the EDX right after it. Its quite simple, but harder to tell -> if you MOVe something to a register, it will automatically erase everything that is stored on the destination (register), and replace it with contents specified as the second operand (source, in the INTEL syntax). But if you have some high number stored in EDX (full 32bit number, like 0FFFFFFFFh), and you would just do MOV DX, 5, I think the CPU will leave the 32bit part "as it is"... Correct me if this is wrong please.
By the way, 0x2 is the same as 2, and 0x0 is the same as XORing the same register with the same (it is faster as you already know, but noticeable maybe only on eerly 8086/80186/V30 etc. ), or 0x0 = 0 simply. Save two bytes of "0x" in your asm code
JNE means "jump if not eqal", you are right , so if CMP EDX,0 ; JNE NOTPRIME would jump to label NOTPRIME if EDX is not 0. I think you already know that
Regards
inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Derrick operating system: http://derrick.xf.cz (Slovak and English )
My DIV explanation:
To divide 16 by 4:
mov ax,10h
mov bx,4
div bx
; now in AX there should be 4
To divide 16 by 4:
mov ax,10h
mov bx,4
div bx
; now in AX there should be 4
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Derrick operating system: http://derrick.xf.cz (Slovak and English )
...and DX should hold the remainderyes, and bx should hold the remainder right? = 0;
Regards
inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Derrick operating system: http://derrick.xf.cz (Slovak and English )
You have ZX Spectrum 81? ... in times of USSR and Czechoslovakia (<1991), you know how the computer (ordinary 286 ) was expensive? I had the only microcomputer Didaktik in my house [along with 1997], and it was borrowed too Ah, the good old days
Regards
inflater
Regards
inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Derrick operating system: http://derrick.xf.cz (Slovak and English )
A snippet of code from mikeos handbook:
makes sence but wouldnt this be the same yet one intruction shorter yet give the same result?:
allso i wouldnt be surprised if ADD uses more clockcycles than mov, in which case it could be a god thing writing:
mov ax,07C0h
instead of
add ax,512
are all this just wrong assumtions?
nb: im not critisising the handbook here, i just wonder if im right...
Code: Select all
BITS 16
start:
mov ax, 07C0h ; Set up 4K stack space after this bootloader
add ax, 512
mov ss, ax
mov sp, 4096
mov ax, 07C0h ; Set data segment to where we're loaded
mov ds, ax
Code: Select all
BITS 16
start:
mov ax, 07C0h ; Set data segment to where we're loaded
mov ds, ax
add ax, 512 ; Set up 4K stack space after this bootloader
mov ss, ax
mov sp, 4096
mov ax,07C0h
instead of
add ax,512
are all this just wrong assumtions?
nb: im not critisising the handbook here, i just wonder if im right...
Last edited by Zacariaz on Wed Sep 26, 2007 12:50 pm, edited 1 time in total.