Click to See Complete Forum and Search --> : Need assembly help QUICK....


Minime80
01-30-2002, 05:31 AM
Here's my dilemma. I've got an assignment due tomorrow, but haven't gotten around to putting Linux back on my machine at home yet. I can ssh to the school's machine's, but they're SPARC's. Anyways, this means I can't compile or test my stupid little program on anything before I turn it in, so I'm going to put the code here (it's short), and if anybody sees a problem with it let me know so I can fix it before I have to turn it in. Thanks...

Here's the code I've got (we're using NASM)
section .data
mystr1: db "S t a r t", 10
mystr1len: dd $-mystr1
mystr2: db "The char should be 'X', is: '"
mystr2len: dd $-mystr2
mychar: db 'X'
mycharlen: dd $-mychar
mystr3: db "'", 10
mystr3len: dd $-mystr3
mystr4: db "The E N D", 10
mystr4len: dd $-mystr4

section .text
global main
main:
push ebx
push ecx
push edx

mov eax, 4
mov ebx, 1
mov ecx, mystr1
mov edx, dword [mystr1len]
int 0x80

mov eax, 4
mov ebx, 1
mov ecx, mystr2
mov edx, dword [mystr2len]
int 0x80

mov eax, 4
mov ebx, 1
mov ecx, mychar
mov edx, dword [mycharlen]
int 0x80

mov eax, 4
mov ebx, 1
mov ecx, mystr3
mov edx, dword [mystr3len]
int 0x80

mov eax, 4
mov ebx, 1
mov ecx, mystr4
mov edx, dword [mystr4len]
int 0x80

pop edx
pop ecx
pop ebx

ret
Oh, it's supposed to output this to the terminal:
S t a r t
The char should be 'X', is: 'X'
The E N D

bugfix
01-30-2002, 09:58 AM
At a cursory glane it looks fine to me.

[ 30 January 2002: Message edited by: bugfix ]

bugfix
01-30-2002, 10:06 AM
Oh yeah, you can get NASM for Windows so if you have that installed then use that!

Minime80
01-30-2002, 04:11 PM
Yeah, I found that NASM for windows and that's what I originally wrote it on. Then I tried to compile it and NASM kept giving me some error code 2 and complained about not being open the error log.


I also realized that the interrupts to output to STDOUT are different on all the operating systems. DOS/Win uses 21h I think, Linux uses 0x80 or 80h, and I've no idea what SPARC/Solaris use which is why it didn't work when I tried it on the school's machines.


It probably would be too much trouble to change between the different interrupts to test it, but it's the last minute and as you can see by the simplicity of the code I'm just starting ASM programming.


Anyways, thanks for looking it over. I'm gonna try and get Linux installed again this weekend so I can play with this stuff.

bugfix
02-04-2002, 08:11 AM
No sweat. Although, I'm not actually that hot on PC Assembler. I work on big multi-million pound IBM mainframes which differ to PC's in numerous ways so I couldn't tell you what interrupt numbers they use for example. If you need a great (and free!) book written by a Dr. of computing then go here:
Assembler Tutorial (http://www.drpaulcarter.com/pcasm/)

Its in PDF and other formats and its great.