I found code in 80836 DOS assembly that I'd like to port to 32-bit Linux assembly, using AT&T syntax.
I found site that explains some differences but only about registers. EX:
- cmp al, 'A' -> cmp 'A', %al
So I got problems converting following code:
input:
mov ah, 00h
int 16h
cmp ah, 1ch
je exit
sub al, 30h
sub al, 37h
sub al, 57h
mov ah, 02h
mov dl, al
int 21h
mov dl, 20h
int 21h
exit:
int 20h
I am converting this code
I think that:
- sub al, 57h ---> sub $0x57, %al and ETC (not sure)
The worst problem is with interrupts since in AT&T assembly it's like:
SYSCALL = 0X80
SYSEXIT = 1
EXIT_SUCCESS = 0
SYSREAD = 3
SYSWRITE = 4
STDIN = 0
STDOUT = 1
And in DOS16, 16h? 20h? 21h? oh man, and even then int 20h acts as interrupt and as value (mov dl, 20h)? so confusing.
Can someone help me?
@EDIT I converted it like this, but I got segmentation fault error. I am almost sure it's about interrupts..
.data
.text
.global _start
_start:
input:
movb $0x0,%ah
int $0x16
cmpb $0x1c,%ah
je exit
number:
cmpb $'0', %al
jb input
cmpb $'9', %al
ja uppercase
subb $0x30,%al
call process
jmp input
uppercase:
cmpb $'A', %al
jb input
cmpb $'F', %al
ja lowercase
subb $0x37,%al
call process
jmp input
lowercase:
cmpb $'a', %al
jb input
cmpb $'f', %al
ja input
subb $0x57,%al
call process
jmp input
loop input
process:
movb $4,%ch
movb $3,%cl
movb %al,%bl
convert:
movb %bl,%al
rorb %cl,%al
andb $01,%al
addb $0x30,%al
movb $0x2,%ah
movb %al,%dl
int $0x21
decb %cl
decb %ch
jnz convert
movb $0x20,%dl
int $0x21
ret
exit:
int $0x20
Anyone?