Ok, I've been trying different tutorials/methods of learning asm and right now I'm reading Dr. Paul Carters tutorial and using NASM and DJGPP to compile. I just got into the conditional/jump section and I wanted to test how the jumps work and ran into a problem. The read_char macro seems to never run and when I look into the registers EAX always has an ascii 'A' (linefeed) in it after the read_char is suppost to run. I can't even enter anything a 'y' or 'n'. I warn you I'm a beginner, and this is a corny test program.
%include "asm_io.inc" segment .data label1 db "Enter your age: ", 0 label2 db "Are your really ", 0 label3 db " (y or n): ", 0 label4 db "Wow, your old!", 0 label5 db "Ok, sorry!", 0 segment .bss age resd 1 yorn resd 1 segment .text global _asm_main _asm_main: enter 0,0 pusha mov eax, label1 call print_string call read_int mov dword [age], eax mov eax, label2 call print_string mov eax, dword [age] call print_int mov eax, label3 call print_string mov eax, 0 call read_char ; <-- will not get input mov dword [yorn], eax cmp dword [yorn], 'y' jnz no call print_nl mov eax, label4 call print_string popa mov eax, 0 leave ret no: call print_nl mov eax, label5 call print_string popa mov eax, 0 leave ret
Any comments or suggestions on how I can make things easier or avoid problems are very welcome. This has been driving me nutts:mad:
Also, I have tried commenting every line before the read_char untill the first call print_string and when I get to the read_int line and comment it also, then it works.