TURING

Computer builds, hardware and software discussion or troubleshooting, including peripherals. Essentially a general place to talk about desktop computers.
wtd
Posts: 157
Joined: Sat Sep 25, 2004 7:21 pm

TURING

Post by wtd »

I see you've worked with MASM. Which version?

Oh, and you haven't had fun until you've written PowerPC assembly. ;)

Archived topic from Iceteks, old topic ID:2393, old post ID:22488
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

TURING

Post by Red Squirrel »

No I just copied that off a site, it's just normal assembly I believe. I did successfully compile a assembly hello world program before though, if that counts as having experience in it. :P

Archived topic from Iceteks, old topic ID:2393, old post ID:22489
Honk if you love Jesus, text if you want to meet Him!
wtd
Posts: 157
Joined: Sat Sep 25, 2004 7:21 pm

TURING

Post by wtd »

Ah, then I'll explain that it's x86 assembly, written for Micrsoft's assembler. I've unfortunately had some experience with it.

Code: Select all

.data
hello_message db 'Hello, World!',0dh,0ah,'$'[code]

This creates a string variable.  0dh and 0ah are hex codes for 13 and 10.  Those are ASCII codes which DOS uses to represent a newline and carriage return.  The $ is the character DOS considers the termination of a string, much as just about every other system considers the null byte.

[code]      mov    ax,@data
     mov    ds,ax[code]

This initializes the computer.  It tells the CPU where to find the data in the program in memory.

[code]      mov    ah,9[code]

This sets the mode to "output a string".

[code]      mov    dx,offset hello_message[code]

This stores the location of the string variable.

[code]      int    21h[code]

This calls interrupt 33 in BIOS which does the actual work of printing out the string.

[code]      mov    ax,4C00h[code]

This sets the mode to "end the program and clean up".

[code]      int    21h[code]

Again, we call interrupt 33 in BIOS which does the exiting and cleaning up. 

[color=#888888][size=85]Archived topic from Iceteks,  old topic ID:2393, old post ID:22490[/size][/color]
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

TURING

Post by Red Squirrel »

Yikes.... how do you know 21h means 33 though? :o

And for the "mov ah,9" line, is it ah,9 that tells it to output as string? So you can put various things there to make it do different things like, output to printer etc?

Archived topic from Iceteks, old topic ID:2393, old post ID:22491
Honk if you love Jesus, text if you want to meet Him!
wtd
Posts: 157
Joined: Sat Sep 25, 2004 7:21 pm

TURING

Post by wtd »

21 in hexidecimal is 33 in decimal. :)

"mov ah, 9" basically means "move 9 into the ah register."

In 32 bit x86 processors, there are four primary general purpose registers (places to store bits of data): EAX, EBX, ECX, and EDX. The E means "extended, since they were originally 16bit registers.

The AX register is the lower 16 bits of the EAX register.

The AH register is the upper 8 bits of the AX register. Similarly, the AL register is the lower 8 bits of the AX register. The AH portion of EAX was the only one that needed to be addressed in that program, so the program doesn't worry about what's in the rest of EAX.

Archived topic from Iceteks, old topic ID:2393, old post ID:22493
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

TURING

Post by Red Squirrel »

Oh I see, yeah I've read about registers and assembly, I understand it a bit. Is it really something worth to know though? Since I want to learn it, but I want to have a good reason to :P

Archived topic from Iceteks, old topic ID:2393, old post ID:22494
Honk if you love Jesus, text if you want to meet Him!
wtd
Posts: 157
Joined: Sat Sep 25, 2004 7:21 pm

TURING

Post by wtd »

If you plan to do embedded programming, it's good to know.

If you plan to do mostly general application-level programming, you're better off studying higher-level design patterns, object-oriented programming, and such.

Archived topic from Iceteks, old topic ID:2393, old post ID:22495
Locked