LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   An as compatibility issue. (https://www.linuxquestions.org/questions/programming-9/an-as-compatibility-issue-890778/)

stf92 07-09-2011 09:13 AM

An as compatibility issue.
 
Kernel 2.6.21.5, Slackware 12.0

Hi:
I have an old source program. I suppose as is the standard assembler under Linux. Has as any option to make it accept the syntax shown in the following fragments from the source?

Fragment 1:
Code:

BASE=          170        ;ports 170h-177h
ICR=          0A0        ;interrupt control register
IMR=          0A1        ;interrupt mask register
EOI=          020        ;end of interrupt command
MSK15=        080        ;interrupt mask
IRQ15=        077        ;irq15 es int77
DEVICE_RESET=  008

lba    struct
msw    dw      ?
lsw    dw      ?
lba    ends

STACK  SEGMENT PARA STACK 'STACK'  ;el "adjetivo" STACK es primordial.
        DB      4096T  DUP('PILA');    16Kb de stack.
STACK  ENDS


_DATA  SEGMENT WORD PUBLIC 'DATA'
ATA_ADDR        DB    0 ;data p2          THIS SIMPLY IS DX IN IN/OUT AX,DX

;ctrl
ATA_nDIOR  =  01      ;bit  p0.0 ;read strobe
ATA_nDIOW  =  02      ;bit  p0.1 ;write strobe
ATA_nRESET  =  04      ;bit  p0.2
ATA_INTRQ  =  08      ;bit  p0.3 ;irq

;data bus
ATA_DATA_LS    DB    0  ;data  p1
ATA_DATA_MS    DB    0  ;data  p3

;LED flags
;
;;;;F_ERROR        bit  p0.4
;;;;F_PLAYING      bit  p0.5


;;;; MENSAJES
BYTE1  DB      '$$$'
CHAR1  DB      '$$'
CRLF    DB      0D,0A,'$'
MSG01  DB      'TERMINATE_WITH_ERROR',0D,0A,'$'
MSG02  db      9,'Unit is an ATAPI device.',0D,0A,'$'
MSG03  db      9,'Unit has removable media.',0D,0A,'$'
MSG04  db      9,'packet size (words): ','$'
MSG05  db      9,'type:',9,'$'
M

Fragment 2:
Code:

packet_13      DB      0
packet_14      DB      0
packet_15      DB      0
_DATA  ENDS

_TEXT  SEGMENT WORD PUBLIC 'CODE'
        ASSUME CS:_TEXT,DS:_DATA,SS:STACK ;linker will make ss:sp point
                                          ; to STACK at run time

  EXTERN delay_100000us: PROC
  db 'Copyright (C) 2000 Jason Nunn <jsno@downunder.net.au>.'

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Read keyboard
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Convierte a mayuscula. Sets cy if no key available.
rks:
  mov  ah,01
  int  16      ;Read Keyboard Status
  jz    rks1    ;jif no key
  ;***************
rks_2:          ;alternate entry point
  mov  ah,00  ;necesario para vaciar el buffer
  int

Fragment 3:
Code:

get_MSF_field:
  call  get_data
  mov  cur_LBA,AL
  mov  cur_LBA+1,AH
  call  prhex
  mov  AL,AH
  call  prhex
  mov  al,' '
  call  writechar

  call  get_data
  mov  cur_LBA+2,AL
  mov  cur_LBA+3,AH
  call  prhex

  mov  AL,AH
  call  prhex
;;  call prcrlf
  mov  al,0d
  call  writechar
  ret

The int nn BIOS calls will have to be replaced, of course.

EDIT:
The syntax is for MASM, an old MS-DOS assembler.

grail 07-09-2011 09:43 AM

Quote:

Has as any option to make it accept the syntax shown in the following fragments from the source?
Are you implying that you have tried to assemble this code and have received errors?

My assembler is a little rusty but maybe if you showed the errors people could provide a solution.

stf92 07-09-2011 09:50 AM

If the code window makes it difficult to read atapi.err please let me know. I can strip off the code, /code tokens.

Code:

semoi@darkstar:~/ata$ head -50  atapi.err
atapi.a: Assembler messages:
atapi.a:50: Error: unknown pseudo-op: `.radix'
atapi.a:51: Error: unknown pseudo-op: `.286'
atapi.a:53: Error: no such instruction: `ctrl bus'
atapi.a:55: Error: junk at end of line, first unrecognized character is `7'
atapi.a:56: Error: junk at end of line, first unrecognized character is `+'
atapi.a:57: Error: junk at end of line, first unrecognized character is `|'
atapi.a:58: Error: junk at end of line, first unrecognized character is `+'
atapi.a:61: Error: no such instruction: `move MACRO $T,$S'
atapi.a:62: Error: suffix or operands invalid for `mov'
atapi.a:63: Error: no instruction mnemonic suffix given and no register operands; can't size instruction
atapi.a:64: Error: no such instruction: `endm'
atapi.a:66: Error: junk `$T' after expression
atapi.a:66: Error: suffix or operands invalid for `movd'
atapi.a:67: Error: suffix or operands invalid for `mov'
atapi.a:68: Error: no instruction mnemonic suffix given and no register operands; can't size instruction
atapi.a:69: Error: suffix or operands invalid for `mov'
atapi.a:70: Error: no instruction mnemonic suffix given and no register operands; can't size instruction
atapi.a:71: Error: suffix or operands invalid for `mov'
atapi.a:72: Error: no instruction mnemonic suffix given and no register operands; can't size instruction
atapi.a:73: Error: suffix or operands invalid for `mov'
atapi.a:74: Error: no instruction mnemonic suffix given and no register operands; can't size instruction
atapi.a:75: Error: no such instruction: `endm'
atapi.a:77: Error: no such instruction: `ports 170h-177h'
atapi.a:78: Error: junk at end of line, first unrecognized character is `A'
atapi.a:78: Error: no such instruction: `interrupt control register'
atapi.a:79: Error: junk at end of line, first unrecognized character is `A'
atapi.a:79: Error: no such instruction: `interrupt mask register'
atapi.a:80: Error: no such instruction: `end of interrupt command'
atapi.a:81: Error: junk at end of line, first unrecognized character is `8'
atapi.a:81: Error: no such instruction: `interrupt mask'
atapi.a:82: Error: no such instruction: `irq15 es int77'
atapi.a:83: Error: junk at end of line, first unrecognized character is `8'
atapi.a:85: Error: no such instruction: `lba struct'
atapi.a:86: Error: no such instruction: `msw dw?'
atapi.a:87: Error: no such instruction: `lsw dw?'
atapi.a:88: Error: no such instruction: `lba ends'
atapi.a:90: Error: no such instruction: `stack SEGMENT PARA STACK 83TACK32'
atapi.a:90: Error: no such instruction: `el "adjetivo"STACK es primordial.'
atapi.a:91: Error: no such instruction: `db 4096T DUP(80ILA41'
atapi.a:91: Error: junk at end of line, first unrecognized character is `1'
atapi.a:92: Error: no such instruction: `stack ENDS'
atapi.a:95: Error: invalid character '_' in mnemonic
atapi.a:95: Error: no such instruction: `data p2 THIS SIMPLY IS DX IN IN/OUT AX,DX'
atapi.a:97: Error: no such instruction: `ctrl'
atapi.a:98: Error: no such instruction: `bit p0.0'
atapi.a:98: Error: no such instruction: `read strobe'
atapi.a:99: Error: no such instruction: `bit p0.1'
atapi.a:99: Error: no such instruction: `write strobe'
atapi.a:100: Error: no such instruction: `bit p0.2'
semoi@darkstar:~/ata$


stf92 07-09-2011 10:09 AM

I read the comment character for i386 is '#'. But this source uses ';' for comments. To change them by hand would be tiresome. To automaticly change them with the editor could replace a semicolon that should not be changed. Anyways there are quite a lot of errors cause by the semicolon.

stf92 07-09-2011 11:07 AM

as thought as was using AT&T syntax. I put '.intel_syntax noprefix' and the error count went down from 779 to 564. The MASM syntax is essentially Intel syntax. Namely, it is the same for all CPU (80x86) instructions.


All times are GMT -5. The time now is 01:30 AM.