people on this forum (back in october 2001) asked about assembly, since I just started revisiting the forums I guess I can give a time-wasting example of a C++ compiled 8086asm example (compiled with g++)
is all asm for:Code:.file "main.cpp"
.version "01.01"
gcc2_compiled.:
.section .rodata
.LC0:
.string "Enter your first name: "
.LC1:
.string "Enter your last name: "
.LC2:
.string " "
.LC3:
.string " characters"
.LC4:
.string "Your first name has "
.LC5:
.string "Your last name has "
.LC6:
.string "Your name has a total of "
.text
.align 4
.globl main
.type main,@function
main:
.LFB1:
pushl %ebp
.LCFI0:
movl %esp, %ebp
.LCFI1:
subl $168, %esp
.LCFI2:
subl $8, %esp
pushl $.LC0
pushl $cout
.LCFI3:
call __ls__7ostreamPCc
addl $16, %esp
subl $8, %esp
leal -56(%ebp), %eax
pushl %eax
pushl $cin
call __rs__7istreamPc
addl $16, %esp
movl $0, -12(%ebp)
.p2align 2
.L3:
leal -56(%ebp), %eax
movl %eax, %edx
movl -12(%ebp), %eax
cmpb $0, (%eax,%edx)
jne .L5
jmp .L4
.p2align 2
.L5:
subl $12, %esp
leal -56(%ebp), %eax
movl %eax, %edx
movl -12(%ebp), %eax
movsbl (%eax,%edx),%eax
pushl %eax
call tolower
addl $16, %esp
movl %eax, -92(%ebp)
leal -56(%ebp), %eax
movl %eax, %edx
movl -12(%ebp), %eax
movb -92(%ebp), %cl
movb %cl, (%eax,%edx)
leal -12(%ebp), %eax
incl (%eax)
jmp .L3
.p2align 2
.L4:
subl $12, %esp
movsbl -56(%ebp),%eax
pushl %eax
call toupper
addl $16, %esp
movl %eax, -96(%ebp)
movb -96(%ebp), %al
movb %al, -56(%ebp)
movl $0, -16(%ebp)
subl $8, %esp
pushl $.LC1
subl $12, %esp
pushl $endl__FR7ostream
pushl $cout
.LCFI4:
call __ls__7ostreamPFR7ostream_R7ostream
addl $20, %esp
movl %eax, -100(%ebp)
pushl -100(%ebp)
.LCFI5:
call __ls__7ostreamPCc
addl $16, %esp
subl $8, %esp
leal -88(%ebp), %eax
pushl %eax
pushl $cin
call __rs__7istreamPc
addl $16, %esp
.p2align 2
.L6:
leal -88(%ebp), %eax
movl %eax, %edx
movl -16(%ebp), %eax
cmpb $0, (%eax,%edx)
jne .L8
jmp .L7
.p2align 2
.L8:
subl $12, %esp
leal -88(%ebp), %eax
movl %eax, %edx
movl -16(%ebp), %eax
movsbl (%eax,%edx),%eax
pushl %eax
call tolower
addl $16, %esp
movl %eax, -104(%ebp)
leal -88(%ebp), %eax
movl %eax, %edx
movl -16(%ebp), %eax
movb -104(%ebp), %cl
movb %cl, (%eax,%edx)
leal -16(%ebp), %eax
incl (%eax)
jmp .L6
.p2align 2
.L7:
subl $12, %esp
movsbl -88(%ebp),%eax
pushl %eax
call toupper
addl $16, %esp
movl %eax, -108(%ebp)
movb -108(%ebp), %al
movb %al, -88(%ebp)
subl $8, %esp
pushl $endl__FR7ostream
subl $12, %esp
leal -88(%ebp), %eax
pushl %eax
subl $12, %esp
pushl $.LC2
subl $12, %esp
leal -56(%ebp), %eax
pushl %eax
subl $12, %esp
pushl $endl__FR7ostream
pushl $cout
.LCFI6:
call __ls__7ostreamPFR7ostream_R7ostream
addl $20, %esp
movl %eax, -112(%ebp)
pushl -112(%ebp)
call __ls__7ostreamPCc
addl $20, %esp
movl %eax, -116(%ebp)
pushl -116(%ebp)
call __ls__7ostreamPCc
addl $20, %esp
movl %eax, -120(%ebp)
pushl -120(%ebp)
call __ls__7ostreamPCc
addl $20, %esp
movl %eax, -124(%ebp)
pushl -124(%ebp)
.LCFI7:
call __ls__7ostreamPFR7ostream_R7ostream
addl $16, %esp
subl $8, %esp
pushl $endl__FR7ostream
subl $12, %esp
pushl $.LC3
subl $12, %esp
pushl -12(%ebp)
subl $12, %esp
pushl $.LC4
subl $12, %esp
pushl $endl__FR7ostream
pushl $cout
.LCFI8:
call __ls__7ostreamPFR7ostream_R7ostream
addl $20, %esp
movl %eax, -128(%ebp)
pushl -128(%ebp)
call __ls__7ostreamPCc
addl $20, %esp
movl %eax, -132(%ebp)
pushl -132(%ebp)
call __ls__7ostreami
addl $20, %esp
movl %eax, -136(%ebp)
pushl -136(%ebp)
call __ls__7ostreamPCc
addl $20, %esp
movl %eax, -140(%ebp)
pushl -140(%ebp)
.LCFI9:
call __ls__7ostreamPFR7ostream_R7ostream
addl $16, %esp
subl $8, %esp
pushl $endl__FR7ostream
subl $12, %esp
pushl $.LC3
subl $12, %esp
pushl -16(%ebp)
subl $12, %esp
pushl $.LC5
pushl $cout
.LCFI10:
call __ls__7ostreamPCc
addl $20, %esp
movl %eax, -144(%ebp)
pushl -144(%ebp)
call __ls__7ostreami
addl $20, %esp
movl %eax, -148(%ebp)
pushl -148(%ebp)
call __ls__7ostreamPCc
addl $20, %esp
movl %eax, -152(%ebp)
pushl -152(%ebp)
.LCFI11:
call __ls__7ostreamPFR7ostream_R7ostream
addl $16, %esp
subl $8, %esp
pushl $endl__FR7ostream
subl $12, %esp
pushl $.LC3
subl $12, %esp
movl -16(%ebp), %eax
addl -12(%ebp), %eax
pushl %eax
subl $12, %esp
pushl $.LC6
pushl $cout
.LCFI12:
call __ls__7ostreamPCc
addl $20, %esp
movl %eax, -156(%ebp)
pushl -156(%ebp)
call __ls__7ostreami
addl $20, %esp
movl %eax, -160(%ebp)
pushl -160(%ebp)
call __ls__7ostreamPCc
addl $20, %esp
movl %eax, -164(%ebp)
pushl -164(%ebp)
.LCFI13:
call __ls__7ostreamPFR7ostream_R7ostream
addl $16, %esp
movl $0, %eax
leave
ret
.LFE1:
.Lfe1:
.size main,.Lfe1-main
.section .eh_frame,"aw",@progbits
__FRAME_BEGIN__:
.4byte .LLCIE1
.LSCIE1:
.4byte 0x0
.byte 0x1
.byte 0x0
.byte 0x1
.byte 0x7c
.byte 0x8
.byte 0xc
.byte 0x4
.byte 0x4
.byte 0x88
.byte 0x1
.align 4
.LECIE1:
.set .LLCIE1,.LECIE1-.LSCIE1
.4byte .LLFDE1
.LSFDE1:
.4byte .LSFDE1-__FRAME_BEGIN__
.4byte .LFB1
.4byte .LFE1-.LFB1
.byte 0x4
.4byte .LCFI0-.LFB1
.byte 0xe
.byte 0x8
.byte 0x85
.byte 0x2
.byte 0x4
.4byte .LCFI1-.LCFI0
.byte 0xd
.byte 0x5
.byte 0x4
.4byte .LCFI3-.LCFI1
.byte 0x2e
.byte 0x10
.byte 0x4
.4byte .LCFI4-.LCFI3
.byte 0x2e
.byte 0x14
.byte 0x4
.4byte .LCFI5-.LCFI4
.byte 0x2e
.byte 0x10
.byte 0x4
.4byte .LCFI6-.LCFI5
.byte 0x2e
.byte 0x14
.byte 0x4
.4byte .LCFI7-.LCFI6
.byte 0x2e
.byte 0x10
.byte 0x4
.4byte .LCFI8-.LCFI7
.byte 0x2e
.byte 0x14
.byte 0x4
.4byte .LCFI9-.LCFI8
.byte 0x2e
.byte 0x10
.byte 0x4
.4byte .LCFI10-.LCFI9
.byte 0x2e
.byte 0x14
.byte 0x4
.4byte .LCFI11-.LCFI10
.byte 0x2e
.byte 0x10
.byte 0x4
.4byte .LCFI12-.LCFI11
.byte 0x2e
.byte 0x14
.byte 0x4
.4byte .LCFI13-.LCFI12
.byte 0x2e
.byte 0x10
.align 4
.LEFDE1:
.set .LLFDE1,.LEFDE1-.LSFDE1
.ident "GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.0)"
Makes ya appreciate C++ eh? (Hopefully C more)Code:/*
* main.c
* String Experiment
* written on Microsoft Visual C++ 6.0 Standard Edition
* compiled with no errors
* compiled on 4/23/02
* Free to distribute and claim as your own!
*/
///////HEADERS//////////
#include <iostream.h>
#include <ctype.h>
#include <string.h>
////END HEADERS/////////
////BEGIN MAIN////
int main()
{
// global declarations
int length;
int lengthb;
char firstName[20];
char lastName[20];
// end declarations
cout<<"Enter your first name: "; //prompt name
cin>>firstName; // STDIN > firstName
length = 0; // Set length to 0
while(firstName[length] != NULL) // As long as there are non NULL Characters in firstName
{ //continue the loop
firstName[length] = tolower(firstName[length]); //Set all characters to lower case
length++; // length increases at auto increment
}
firstName[0] = toupper(firstName[0]); //Set first char of firstName to upper case
lengthb = 0; // second length identification is set to 0 for While loop
cout<<endl<<"Enter your last name: "; //prompts for last name
cin>>lastName; // STDIN > lastName
while(lastName[lengthb] != NULL) // begin while loop
{
lastName[lengthb] = tolower(lastName[lengthb]); //Set all characters to lower case
lengthb++; // second length declaration is set to auto increment in loop
}
lastName[0] = toupper(lastName[0]); // first character of lastName is set to upper case
cout<<endl<<firstName<<" "<<lastName<<endl; // display firstName lastName
cout<<endl<<"Your first name has "<<length<<" characters"<<endl; //display length
cout<<"Your last name has "<<lengthb<<" characters"<<endl; //display length(2)
cout<<"Your name has a total of "<<length+lengthb<<" characters"<<endl; //display the sum
return 0; // return from main with no erros unless processor or kernel says otherwise
}
////END MAIN////