Page 2 of 4

Posted: Thu Sep 13, 2007 11:24 am
by inflater
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

Posted: Thu Sep 13, 2007 11:37 am
by Zacariaz
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
Hello world is the easiest thing in the world and works perfectly.
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 ;)

Posted: Thu Sep 13, 2007 11:40 am
by Zacariaz

Posted: Fri Sep 14, 2007 8:37 am
by inflater
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 :lol:). :D 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. :D), or 0x0 = 0 simply. :) Save two bytes of "0x" in your asm code :lol:

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

Posted: Fri Sep 14, 2007 8:58 am
by inflater
My DIV explanation:

To divide 16 by 4:

mov ax,10h
mov bx,4
div bx

; now in AX there should be 4 ;)

Posted: Fri Sep 14, 2007 9:01 am
by Zacariaz
lets see... the first post is from 11 Jan 2007, so its not so old as i thought, still i only posted it to give an example to what i was considering doing as one of my first programs.
Anyway thanks for the tips and stuff ;)

Posted: Fri Sep 14, 2007 9:03 am
by Zacariaz
inflater wrote:My DIV explanation:

To divide 16 by 4:

mov ax,10h
mov bx,4
div bx

; now in AX there should be 4 ;)
yes, and bx should hold the remainder right? = 0;

Posted: Fri Sep 14, 2007 9:37 am
by inflater
yes, and bx should hold the remainder right? = 0;
...and DX should hold the remainder :D

Regards
inflater

Posted: Fri Sep 14, 2007 9:43 am
by Zacariaz
oh well, bx, dx, zx81 (yes i have one of those), its easy to get confused ;)

Posted: Fri Sep 14, 2007 9:48 am
by inflater
You have ZX Spectrum 81? :shock:... in times of USSR and Czechoslovakia (<1991), you know how the computer (ordinary 286 :lol:) was expensive? :D I had the only microcomputer Didaktik in my house [along with 1997], and it was borrowed too :) Ah, the good old days :P

Regards
inflater

Posted: Fri Sep 14, 2007 9:53 am
by Zacariaz
I got it from a family mamber of mine, i actually never did learn how to use it. but i do have those 64kb of extra ram ;) Maybe i should write an os for that? lol

Posted: Fri Sep 21, 2007 7:57 am
by Zacariaz
A snippet of code from mikeos handbook:

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
makes sence but wouldnt this be the same yet one intruction shorter yet give the same result?:

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
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...

Posted: Fri Sep 21, 2007 3:08 pm
by frank
Maybe it's one of those let the code document itself things.

Posted: Fri Sep 21, 2007 3:12 pm
by Zacariaz
Im really just interested in if im right or not, and to tell someone of, cause im definently not qualified for that...

Posted: Fri Sep 21, 2007 3:27 pm
by frank
Yes both code items you posted will have same results. One just looks nicer.