Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Assembly Language 80386

Name: Anonymous 2010-11-20 18:24

ok, so here's my problem:
main:
        mov     eax, prompt0      ; print out prompt
        call    print_string
        call    read_char
       
        cmp             eax, 'a'
        je        near addition
        cmp             eax, 's'
        je         near subtraction
        cmp        eax, 'm'
        je         near multiplication
        cmp             eax, 'd'
        je        near division
        cmp        eax, 'o'
        je         near modulo
        cmp        eax, 'x'
        je        exit
        jmp     main
/code

for some reason when I run my program, it prints that output msg twice.  this is the only part of my program that has:
mov     eax, prompt0      ; print out prompt
call    print_string

So I'm at a loss as to why the hell it would double up on prompt0 the second time through.  anyone have any thoughts on this?

Name: Anonymous 2010-11-20 18:26

Use code tags.

Name: Anonymous 2010-11-20 18:26

/code
At least he tried.

Name: op 2010-11-20 18:33

sorry, first time posting here
<code>
main:
        mov     eax, prompt0      ; print out prompt
        call    print_string
        call    read_char
      
        cmp             eax, 'a'
        je        near addition
        cmp             eax, 's'
        je         near subtraction
        cmp        eax, 'm'
        je         near multiplication
        cmp             eax, 'd'
        je        near division
        cmp        eax, 'o'
        je         near modulo
        cmp        eax, 'x'
        je        exit
        jmp     main
</code>

Name: op 2010-11-20 18:33

is there somewhere with the code tag syntax?

Name: Anonymous 2010-11-20 18:35

[code][/code]

Name: Anonymous 2010-11-20 18:35

obviously read_char returns a value that is not one of those choices and then loop

Name: Anonymous 2010-11-20 18:36

Fucking lurking, how does it work?!

Name: Anonymous 2010-11-20 18:42

does read_char require input from the keyboard before it does that? and why doesn't it keep going and go into a loop if that's the problem?  it's weird.

main:
        mov     eax, prompt0      ; print out prompt
        call    print_string
        call    read_char
      
        cmp             eax, 'a'
        je        near addition
        cmp             eax, 's'
        je         near subtraction
        cmp        eax, 'm'
        je         near multiplication
        cmp             eax, 'd'
        je        near division
        cmp        eax, 'o'
        je         near modulo
        cmp        eax, 'x'
        je        exit
        jmp     main

Name: Anonymous 2010-11-20 18:47

It's really not weird at all. Print out the fucking charcode and see for yourself.

Name: Anonymous 2010-11-20 18:54


read_char is a built in assembly language function that reads a single character from the keyboard and stores its ASCII code into the EAX register.  the program is acting like print_string is being called twice in a row, it doesn't pause to read_char between them, instead of

string:

its coming out as

string:string:

after the first time through the program

Name: Anonymous 2010-11-20 18:55

Your problem is with print_string and you haven't given us any information on that at all?

Name: op 2010-11-20 19:03

sorry, print_string just prints the contents of the EAX register.

basically, i'm just moving the output string into EAX, outputting it, then it's supposed to prompt for input from the user, which it does, but after the first time through the program its like print_string gets called twice, it's weird.

sorry if i seem like a noob ˆˆ;

Name: Anonymous 2010-11-20 19:12

>>13
Your blatant refusal to take the advice offered makes you seem more like a troll.

Name: Anonymous 2010-11-20 19:20

>>14 what advice? so far I've had people tell me to look at read_int and print_string, but they are both built into my assembler, and one just waits for user input and stores it in EAX, and the other prints out the contents of EAX.
and who trolls a programming BBS?? 

I guess it's some kind of bug, i don't know

Name: Anonymous 2010-11-20 19:22

>>13
^^;
Why I feel like I have bitch tits?

Name: Anonymous 2010-11-20 19:30

Sure it doesn't read the character into the al sub-register?

Name: Anonymous 2010-11-20 19:30

>>15
The advice in >>7,10 should contain the answer, if I remember the format of this troll correctly.

Name: op 2010-11-20 19:36

>>17 i think so
>>18 7 doesnt tell me anything i don't already know, and 10, what's charcode?? i figured he meant the code for the function read_char, but it's built in

Name: Anonymous 2010-11-20 19:39

>>19

>>17 i think so

In that case, enjoy your problem.

Name: Anonymous 2010-11-20 19:39

Honestly, it's like helping someone with their troll homework.

Name: op 2010-11-20 19:43

some of you guys are, like, too hostile.  too much time on /b/ i figure.  anyway figured it might have been a waste of my time to ask some strangers on the internet.

thank you to the people who tried to help, take care.

Name: Anonymous 2010-11-20 19:44

>>22

The answer is actually in this thread but you're apparently too stupid to read.

Name: Anonymous 2010-11-20 19:56

some of you guys are, like, too hostile.  too much time on /b/ i figure.
I have humongous bitch tits.

Name: Anonymous 2010-11-20 19:58

>>24
Back to /b/, please.

Name: Anonymous 2010-11-20 20:00

>>25
Stop trolling, Sussman.

Name: VIPPER 2010-11-21 3:11

Maybe just dont fucking use these routines OP, use others.

Name: Anonymous 2010-11-21 5:06

Use a god damn debugger and step through the code to see what happens.

Name: Anonymous 2010-11-21 16:40

So is it just me or eax a little big for a single ASCII character?

Name: Anonymous 2010-11-21 17:55

>>28
Say that to my face and see what happens.

Name: eax 2010-11-21 19:37

>>29
ARE YOU CALLING ME FAT?

Name: Anonymous 2010-11-22 6:12

This need macroses. Just think about it

        invoke print_string, prompt0
        call    read_char
        jmpifeq  eax, 'a', addition
        jmpifeq  eax, 's', subtraction
        jmpifeq  eax, 'm', multiplication
        jmpifeq  eax, 'd', division
        jmpifeq  eax, 'o', modulo
        jmpifeq  eax, 'x', exit
        jmp     main

Almost as cool as ML with its pattern matching!

both built into my assembler
IHBT

Name: Anonymous 2010-11-22 10:55

C is just asm with macros.

Name: Anonymous 2010-11-22 11:00

>>31

No man I like my registers with a little meat on them ;-), just saying that al is the perfect size for a single ASCII character so that cmp al, 'a' might be a more apt comparison.

Name: Anonymous 2010-11-22 12:54

>>34
;-)
GTFO.

Name: Anonymous 2010-11-26 0:49

Don't change these.
Name: Email:
Entire Thread Thread List